I have a batch script that prepares some files, executes a program (
.exe) and then deletes said files.
This task should run hourly, so I'm trying to configure this using Scheduled Tasks. The problem is that the previously mentioned program does not run properly when invoked from the task (neither via the
.bat script, nor when calling the
.exe directly), but I don't get any warning or error messages in the logs.
The task is configured to run as a Windows Service Account that has all the privileges set properly. When using this account to logon via RDP, I can execute the
.exe directly without problems, but still the task appears to do nothing. This is easily observed because the program always modifies a file, and the modified on timestamp does not change through the task.
In the scheduled task logs I get the information messages for the task starting a process, exiting, etc. The "result code", however, is
111 (tried to Google this without luck, the only association I get is "file name is too long", which is just completely irrelevant AFAIK). In the application logs, I get absolutely nothing.
What I suspect is the problem
The program is an old monstrosity that spawns some sort of splash screen (it's actually a normal window), even though the GUI is not needed because it requires no interaction and closes itself after operations. The window appears for about 2 seconds.
I suspect that this requirement for a GUI has something to do with the task failing, but I'm not sure. When I log in with the user that the task runs under (via RDP), no window appears when I start the scheduled task.
Edit about the GUI
I've built a very small C# executable that launches the program without the main window (using
ProcessStartInfo.WindowStyle = ProcessWindowStyle.Hidden). Even this way, the scheduled task still does not succeed to launch the program correctly, but the return code is now
When I configure the task to say "run whether the user is logged on or not", and the
run with highest privileges option is unchecked, the error value is
What can I do to troubleshoot?
OS = Windows Server 2008 R2 SP1
If more info is needed, please let me know in the comments.