Skip to content

Instantly share code, notes, and snippets.

@stutstev
Last active August 23, 2023 21:16
Show Gist options
  • Select an option

  • Save stutstev/049b7ebf4be1d7f1f8578a466e92ba94 to your computer and use it in GitHub Desktop.

Select an option

Save stutstev/049b7ebf4be1d7f1f8578a466e92ba94 to your computer and use it in GitHub Desktop.

Revisions

  1. stutstev revised this gist Aug 23, 2023. 1 changed file with 1 addition and 4 deletions.
    5 changes: 1 addition & 4 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,5 @@
    :: Allows admins to execute batch scripts on
    :: remote Windows hosts when their
    :: technically inept, impressionable bosses
    :: block PowerShell out of unwarranted
    :: security fears.
    :: remote Windows hosts.

    @echo off
    set CMD=%1
  2. stutstev revised this gist May 27, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,8 @@
    :: Allows admins to execute batch scripts on
    :: remote Windows hosts when their
    :: technically inept, impressionable bosses
    :: block PowerShell out of unwarranted security
    :: fears.
    :: block PowerShell out of unwarranted
    :: security fears.

    @echo off
    set CMD=%1
  3. stutstev revised this gist May 27, 2023. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,8 @@
    :: Allows admins to execute batch scripts on
    :: remote Windows hosts when their technically
    :: inept, impressionable bosses block PowerShell
    :: out of unwarranted security fears.
    :: remote Windows hosts when their
    :: technically inept, impressionable bosses
    :: block PowerShell out of unwarranted security
    :: fears.

    @echo off
    set CMD=%1
  4. stutstev revised this gist May 27, 2023. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    :: Allows admins to execute batch scripts on remote
    :: Windows hosts when their technically inept,
    :: impressionable bosses block PowerShell out of
    :: unwarranted security fears.
    :: Allows admins to execute batch scripts on
    :: remote Windows hosts when their technically
    :: inept, impressionable bosses block PowerShell
    :: out of unwarranted security fears.

    @echo off
    set CMD=%1
  5. stutstev revised this gist May 27, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    :: Allows admins to execute batch scripts on remote
    :: Windows hosts when their technically ignorant,
    :: Windows hosts when their technically inept,
    :: impressionable bosses block PowerShell out of
    :: security fears.
    :: unwarranted security fears.

    @echo off
    set CMD=%1
  6. stutstev revised this gist May 27, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,7 @@
    :: Allows admins to execute batch scripts on remote
    :: Windows hosts when their ignorant and impressionable
    :: bosses block PowerShell out of security fears.
    :: Windows hosts when their technically ignorant,
    :: impressionable bosses block PowerShell out of
    :: security fears.

    @echo off
    set CMD=%1
  7. stutstev revised this gist May 27, 2023. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    :: Allows admins to execute batch scripts on remote Windows hosts when their
    :: ignorant, impressionable bosses block PowerShell out of security fears.
    :: Allows admins to execute batch scripts on remote
    :: Windows hosts when their ignorant and impressionable
    :: bosses block PowerShell out of security fears.

    @echo off
    set CMD=%1
  8. stutstev revised this gist May 27, 2023. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    :: Runs DOS batch scripts on remote Windows hosts.
    :: Allows admins to execute batch scripts on remote Windows hosts when their
    :: ignorant, impressionable bosses block PowerShell out of security fears.

    @echo off
    set CMD=%1
  9. stutstev created this gist Jan 21, 2023.
    52 changes: 52 additions & 0 deletions quickdeploy.cmd
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    :: Runs DOS batch scripts on remote Windows hosts.

    @echo off
    set CMD=%1
    set SYS=%2
    set VERBOSITY=%3

    set CMD=%CMD:"=%
    set SYS=%SYS:"=%

    set TASK_NAME=quickdeploy
    set TASK_CMD=cmd.exe /c '%CMD%'

    :: MAIN

    echo.
    echo Running script on "%SYS%"...
    echo.

    if "%VERBOSITY%" == "-v" (
    echo Command: %CMD%
    echo.
    )

    ping -n 1 "%SYS%" 1>nul || (
    echo ERROR: Could not receive ICMP ping response from "%SYS%".
    goto END
    )

    schtasks ^
    /create ^
    /tn "%TASK_NAME%" ^
    /tr "%TASK_CMD%" ^
    /s "%SYS%" ^
    /ru "NT AUTHORITY\SYSTEM" ^
    /sc once ^
    /rl highest ^
    /st 00:00 ^
    /f

    schtasks /run /tn "%TASK_NAME%" /s "%SYS" && ^
    schtasks /delete /tn "%TASK_NAME%" /s "%SYS%" /f >nul 2>&1

    :END

    :: --------
    :: SYNOPSIS
    :: --------
    ::
    :: quickdeploy.cmd script host [-v]
    ::
    :: Example: quickdeploy.cmd \\server\share\script.cmd abc123 -v