Scheduled Task not running properly in the background

Joe
Joe used Ask the Experts™
on
I am trying to move some scheduled tasks from a windows server 2003 server to a 2008 r2 server. I copied the tasks exactly. There are two programs that are supposed to run. 1 gathers statistics and creates 3 excel files. 2. Sends the files to certain distros. The programs work fine when i run them manually but when i run them as a scheduled task it looks like it's running in processes but the excel files aren't created and no email is sent.

I have tried running as "highest privilege"  it also seems to work if i select "run only if user is logged in" but i cannot always stay logged in.

I'm lost please help.

Josef
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Tim PhillipsWindows Systems Administrator
Commented:
Just a thought, but you could try running it with the "system" user account.
NVITEnd-user support
Commented:
What does your manual command line look like? e.g.
program.exe arg1 arg2

The task's Action settings would be...
Program/script: program.exe
Add arguments: arg1 arg2

If you are using CMD.EXE, the task's Action settings would be...
Program/script: cmd.exe
Add arguments: /c arg1 arg2
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

Steven CarnahanAssistant Vice President\Network Manager
Commented:
I have seen some batch files run as scheduled task not work unless the "Start In" is filled in.
JoeSystems Administrator

Author

Commented:
I could try running as system. I am running as a domain admin though I'd think that would be enough.

I am running as a domain admin. I have also tried running as a local administrator account as well
JoeSystems Administrator

Author

Commented:
Hmm.. i will try the arguments. Didn't think of that.
NVITEnd-user support
Commented:
Correction to my post ID: 40885511

If you are using CMD.EXE to run a .bat file, the task's Action settings would be...
Program/script: cmd.exe
Add arguments: /c program.bat arg1 arg2
JoeSystems Administrator

Author

Commented:
Oh wait no the first program is an exe file. It looks like it's using a config file for instruction though.

Josef
Commented:
Is the config file or anything that it is supposed to be creating on a mapped drive.  You may need to use a UNC path instead...
JoeSystems Administrator

Author

Commented:
No it's not creating a mapped drive. It looks like it is running everything locally.


Josef
Steven CarnahanAssistant Vice President\Network Manager
Commented:
Have you tried what I suggested:  

I have seen some batch files run as scheduled task not work unless the "Start In" is filled in.
JoeSystems Administrator

Author

Commented:
Yes i am sorry i did not see that. Start in is filled in.

Josef
JoeSystems Administrator

Author

Commented:
The program is running. Just it runs in the background and since it is doing so it doesn't seem to do what it's intended to do. When it runs in the foreground it works okay.

Josef
Steven CarnahanAssistant Vice President\Network Manager
Commented:
Normally that is a permission issue.  If it is opening a CMD window then verify that the user that is running the task has read/execute permissions to the cmd.exe file located in C:\Windows\System32.
JoeSystems Administrator

Author

Commented:
It does. I am a domain and local admin. I also set the task to run as highest privilege. Unless there is another setting that i do not know about.
NVITEnd-user support
Commented:
Josef,

Have you tried the UNC suggestion by Joe at ID: 40889735. I don't know how your program is written/setup, or if you have the option of fixing it.

If your program assumes the mapped drive exists, you may need to revise it. One option is to create the mapping in your program. That way, you know the mapped drive is there. Another is to replace the mapped drives with the full path.
Steven CarnahanAssistant Vice President\Network Manager
Commented:
I agree with Josef and Joe.  If you are trying to use a mapped drive it won't work.  Remember drives are mapped at logon so if you run a program using a mapped drive when not logged in there will be no mapped drives.  Hard to answer properly without the actual code to look at.
JoeSystems Administrator

Author

Commented:
i think that i found the answer. I will get back with you all in the next day or so. Testing is in progress.
Systems Administrator
Commented:
It was a dumb fix honestly. I spoke with the developer who wrote the program. He debugged the program and saw that it was having an issue finding a cell in excel. Soo.. He googled the fix and it was to go to C:\Windows\SysWOW64\config\systemprofile and create a folder called desktop... That's it.

Josef
Steven CarnahanAssistant Vice President\Network Manager

Commented:
Josef,

Glad you figured that out.  Seems like a strange but common issue. I did a search and found lots of hits with the same solution that worked for most scenarios. There was also a registry hack mentioned but this seems the easier/safer method. One more tool to add to the chest.  :)
JoeSystems Administrator

Author

Commented:
Thanks for all the help.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial