Task Scheduler - I have a .cmd file I'm trying to execute on a regular basis through Task Scheduler. I've set the task so that it points to the cmd file. I want the task to execute even when no one is logged in. I've set the credentials associated with the task to the local service account. When I execute the task, nothing happens. The Last Run Result shows 0x1, this means it didn't execute properly. When I run the file from a command prompt it executes just fine. Any help out there would be appreciated. I would post the code but it has sensitive information in it and I'm not allowed to let the code outside. Thanks
Make a user account, set permissions so the task can run as that user (e.g. folder access permissions), run a command prompt as that user (runas /user:domain\user cmd) then from there try the task.
When that's working, set the scheduled task to run as that user.
Edit: this wont work until you take into account Shane Madden's reply about permissions on c:\windows\system32\cmd.exe as well.
It's unclear from your question whether the task is running as "LOCAL SYSTEM" or a local user that's a service account.
If,
then you'll need to make modifications to the security settings of
cmd.exe
- by default, the NTFS ACL only allows Administrators and interactively logged on users to execute it. (reference)Edit: Oh, and this is only applicable to Windows 2003. I'm up to three baseless assumptions in this answer.. let us know what OS and level of user rights and we should be able to narrow it down.
I had a similar issue because my .cmd file was in C:\ (root). After moving elsewhere, it ran fine from the Task Scheduler. In some corporate environments, there are restrictions at the C:\ root level.
For XP, 2000 and Server 2003 take a look at this MS article "the only way to schedule a task as the System Account is to use AT.EXE to schedule the task"
http://support.microsoft.com/kb/223375
For vista and 2008 this may help https://stackoverflow.com/questions/77528/how-do-you-run-cmd-exe-under-the-local-system-account
Try a
pause
in your script.You will then be able to read the problem.In my case, I got an
access denied
error, since the script started running in\windows\system32
. So, after changing into the correct folder (cd
), it worked.