@ECHO OFF
IF %1]==] GOTO Usage
FOR /F "TOKENS=1,2 DELIMS=/ " %%A IN ("%1") DO SET @DependedServer=%%A&SET @DependedSchtask=%%B
IF ERRORLEVEL 1 (
ECHO ERROR: ** The input parameters - %1 init failed
GOTO ExitError
)
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO ::::: Check and disable depended schtask - %@DependedServer%/%@DependedSchtask%
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
ECHO INFO : ## Check depended schtask - %@DependedServer%/%@DependedSchtask% state ...
SCHTASKS /S %@DependedServer% /QUERY | FIND "%@DependedSchtask%"
SCHTASKS /S %@DependedServer% /CHANGE /TN "%@DependedSchtask%" /DISABLE /RU System
IF ERRORLEVEL 1 (GOTO ExitError)
ECHO INFO : ## Disable depended schtask - %@DependedServer%/%@DependedSchtask% successfully
EXIT /B 0
:ExitError
ECHO Error : ** Disable depended schtask - %@DependedServer%/%@DependedSchtask% failed
EXIT /B 1
:Usage
ECHO Usage: %0 DependedServer/DependedSchtask
ECHO Example: %0 SZGFDEVAP11/SchtaskName