Skip to content

Instantly share code, notes, and snippets.

@speguero
Last active January 22, 2023 01:03
Show Gist options
  • Save speguero/b59970ba2dff35f589c0ad67213f0605 to your computer and use it in GitHub Desktop.
Save speguero/b59970ba2dff35f589c0ad67213f0605 to your computer and use it in GitHub Desktop.
quickdeploy
===========
Runs DOS batch scripts on remote Windows hosts.
Synopsis
--------
quickdeploy.cmd script host [-v]
Example: quickdeploy.cmd \\server\share\script.cmd server123 -v
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment