catching output from schtasks

  • Thread starter Thread starter Kok Yong Lee
  • Start date Start date
K

Kok Yong Lee

Hi there,

I ouwld like to write a batch file that will kick start a schedule task on a
remote machine using the following command

schtasks /run /s cam2 /tn start_test

there will be a number of machines that I will have to start off the tests
in the batch file. How can I catch the return from this command "SUCCESS:
Attempted to run the scheduled task "test"", and act on them appropriately?

thanks.
 
Hi there,

I ouwld like to write a batch file that will kick start a schedule task on a
remote machine using the following command

schtasks /run /s cam2 /tn start_test

there will be a number of machines that I will have to start off the tests
in the batch file. How can I catch the return from this command "SUCCESS:
Attempted to run the scheduled task "test"", and act on them appropriately?

thanks.

for /f "Tokens=1*" %a in ('schtasks /run /s cam2 /tn start_test') do (
if "%%a" EQU "SUCCESS: " (call :suc "%%b") ELSE (call :not "%%b)
)

Jerold Schulman
Windows Server MVP
JSI, Inc.
http://www.jsiinc.com
http://www.jsifaq.com
 
Thanks Jerold,

BTW, where can I find more informatino about the "Tokens=1*" usage in the
example you showed me?

thanks again
 
Kok Yong Lee said:
Thanks Jerold,

BTW, where can I find more informatino about the "Tokens=1*" usage in the
example you showed me?

thanks again


From the prompt, type

FOR /?

(for that matter, SET/? or CALL/? yield interesting information - or in
general, command/? )

The newsgroups alt.msdos.batch or more especially alt.msdos.batch.nt (for
NT/2K/XP) are dedicated to the use of batch in strange and wonderful ways.

HTH

....Bill
 
Back
Top