Program does not run properly as Scheduled Task
I believe your problem has to do with either the permissions of the account being used to run the task, or the context of the account as exists when trying to run the task.
Test for Console Session Requirement
It's possible your .EXE must be run in
Console session (aka Session 0) on the computer. To test for this:
- Configure the task to Run only when user is logged on and specify a task start time of 2 minutes in the future
- Log on to the machine with the same user account used to run the task (preferably log on to the console session, either by physically being at the console or using a remote access program that gives access to the console. To confirm you are using the console session, from a Command Prompt run
QWINSTA, observe the
SESSIONNAMEcolumn, and confirm the
>indicator is next to
console, in other words it should appear as
- Wait for the task to run
If the task runs correctly, try scheduling the task with
SCHTASKS.EXE using the
/IT parameter. Failing that, you may have no choice but to configure the computer to automatically log on as your service user account and run the task as a startup program.
Additionally, as I've already suggested, check the following to confirm the account used to run the task is properly permissioned:
- Grant the account the Logon as a batch job user right (Found in Local Group Policy at
Computer Configuration/Windows Settings/Security Settings/Local Policies/User Rights Assignments)
- Confirm the task is configured to Run with highest privileges
- Confirm the user has full NTFS permissions to all folders & files it must interact with. Make no assumptions; instead confirm by navigating to such file locations and using the
Effective Permissionstab in the file/folder's Properties at
Security > Advanced
Additional things to check/try
- Does the task require access to access to network resources? Things like mapped drives may be present when you logon with the user account, but depending on the server's configuration may not be present in the context of the user account when executed from Task Scheduler.
Add some logging to your batch file. After every line it executes, have it write some output to a log file so you know where it's getting stuck. For example:
@echo off echo Line 1 >> "C:\MyLog.txt" "C:\My Folder\myOldProgram.exe" echo Line 2 >> "C:\MyLog.txt" DEL somefile.dat echo Line 3 >> "C:\MyLog.txt"
Try running your .EXE with
START, for example
START "myTitle" "C:\full\path\to\my.EXE"
I'm responding to an old post in case it helps someone else. I had the same issue. The event log said the program completed normally, but not even the first line of code would write to the log for me. It ended up being the "Start In" option in the Task Scheduler. It occurred to me that the program ran fine from the command line when I was in the current directory. There are manifest files and other dependencies in the same directory. So if you tell the scheduled job to start in the same directory as the EXE, you may get favorable results. It was the solution for me.