catching output from schtasks

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.
 
J

Jerold Schulman

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
 
K

Kok Yong Lee

Thanks Jerold,

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

thanks again
 
B

billious

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top