Sign in with
Sign up | Sign in
Your question
Solved

Schtasks called from batch not recognized

Last response: in Windows 7
Share
September 6, 2012 2:18:34 PM

I have a batchfile that ftp's several other batch files to a computer, then calls one of them which schedules the rest. The scheduler batch file uses the schtasks command. When i run the first batch file, it pulls the files fine but twhen it calls the scheduler, i get the error "'schtasks' is not recognized as an internal or external command, operable program or batch file." However I know that the command is installed on the computer because i can type in 'schtasks' and i get all the current scheduled tasks' information. I can also manually run the second scheduler batch file and it runs. It only fails when the first batch file calls it. The calling statement at the very end of the first batch file is "call C:\batchfiles\scheduler.bat". The scheduler is only four schtasks commands on four lines. Can you help me figure out why the commands fail when called from the first batch file.
a c 367 $ Windows 7
September 6, 2012 3:15:32 PM

Try putting the full path to the schtasks command in the batch file, or are you already doing that?
m
0
l
September 6, 2012 3:22:23 PM

i thought that the schtasks command location was in the $PATH variable. plus i tried running the schtasks in command prompt from several different directories. it worked still. i also tried putting several different cd commands before both my call statment and before the schtasks commands in either batch file. it still failed.
m
0
l
Related resources

Best solution

a c 367 $ Windows 7
September 6, 2012 3:30:20 PM

That error can really only come up form a few things. If the program does not exist, if it's typed wrong, or if the computer can't find it.

Since it works when you run it manually, the program is there. So something is happening when you are running it from the original batch file so it can't find the command. If you put in the full path to it in the second batch file, that should fix it. Make sure you use quotes if the program path has spaces or the short directory names.

Or make the schtasks command part of the first batch file, see if that runs OK.
Share
September 6, 2012 3:30:55 PM

but to better answer your question: no i dont have the full path to schtasks in the batch file. i just say " schtasks ...." for each of my statements.
m
0
l
September 6, 2012 3:44:50 PM

so i tried removing the call statement and putting the schtasks commands in the main file. it still fails with the same error.
m
0
l
September 6, 2012 3:45:35 PM

i should clarify. the move from the ftp works fine, but the scheduling fails due to the schtasks error
m
0
l
September 6, 2012 4:48:28 PM

SOLVED: so i got it working. i played off the advice you gave me about putting the entire filename in the schtasks call. i put a cd to system32 right before all the schtasks calls with the schtasks in the main file. now it works. Thank you for your help.
m
0
l
September 13, 2012 12:36:38 PM

Best answer selected by btl@entrada.
m
0
l
!