I was an ace with Windows 2003 Scheduled Tasks. Everything just worked. This does not seem to be the case with the 2008 Task Scheduler. I need it to run a batch file that calls osql.exe and then copies a newly created file to a network share. Therefore, the task needs to have the password stored so that it can access remote resources. So I let it save the password. I also went into the local security policy and added the user to "task requires that the user account has log on as batch job" permission. If I do:
runas /user:mydomain\myser cmd
then run the batch file, it works every time. If I try to run it from the GUI it will not run, even though it says "Running" in the Status column. The user account I use is a Domain User and nothing more. For the Actions tab, I have the program starting in the directory where the batch file exists.
Any ideas? Does anyone else struggle with this?
Try psexec'ing into the server as the user and running the batch file. You will then likely see the error.
I had a similar problem with batch file running normally but not with 08 R2 Task Scheduler. It would run if "Only run when user logged in", but not when "Run whether user is logged on or not".
Turned out something was trying to access drives by drive letter. I'm not sure if this was programmed directly or 08 was trying to be smart and converting the UNC path to a mapped drive. My ini file for the program only had UNC paths though. Obviously drive letters aren't mapped when user not logged on..
I ended up having to map the drive in the batch file with credentials (it doesn't pass through). It then worked.
This may or may not be a similar issue to you.
Make sure the user running the tasks has premissions to the batch file and any network shares. Then pick "Run whether user is logged on or not" and checking the "Run with highest privileges" checkbox on the General tab.
Start - Administrative Tools -Local Security Policy - Local Policies - Security Options - "Network access: Do not llow storage of passwords and credentials for network authentication" -disabled by default, switch to enabled.
Make a .bat file in your exe' s directory. In first line change to the directory of your exe. In the second line call your exe like this:
pushd "%~dp0"
YourExe.exe
In the task scheduler do not call your exe but call your bat file