Schtasks called from batch not recognized

btl@entrada

Honorable
Sep 6, 2012
8
0
10,510
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.
 
Solution
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.
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.
 
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.
 
Solution
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.