I have a batch file (below) that works perfectly when run, however, when I set up the bat file in the task scheduler it ain't working right. The task scheduler does indeed run the task successfully, so I'm assuming it has to do with permissions for the Administrator regarding the .exe file. I already made sure the admin has permission in the local security options to "logon as a batch job" and I made sure the admin has full control of the entire folder that the .exe is contained in. When I test the batch file manually and it works, I am logged in as the admin.

EDIT: Summary of things asked and answered in comments:

  1. M:\ is a networked drive. It is physically located on this same server, but per requirements of the program, the networked drive letter must be used.
  2. moved bat file to C:\ in the theory that having it on the desktop might be an issue: no change.
  3. When the exe is run, a gui is supposed to launch. This happens when the bat is run manually, but the gui fails to launch when task manager is used. The remainder of the bat runs as intended. Per software developer, gui should be able to run even from task manager and they have not seen this behavior before.

EDIT 2: So I've confirmed that the problem is that the GUI DOES need to launch, contrary to expectations. I can get the task to work by changing to Run only when user is logged on, which causes the UI to appear. However, since this is a server and the task runs in the wee hours of the morning, there usually is not a user logged in. Is there a way to cause the user to log on and off at a specific time? Or another solution other than always leaving a user logged in?

The batch file (REVISED):

netsh interface set interface "Local Area Connection 2" DISABLED
iisreset /stop
timeout /t 120
iisreset /start
netsh interface set interface "Local Area Connection 2" ENABLED
start /d "M:\CBSW" optimize.exe T

The exported XML from the task in task scheduler (revise:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
          <Monday />
          <Thursday />
    <Principal id="Author">
  <Actions Context="Author">
  • Is M: a mapped network drive, or a actual drive local to the system the script is run on? Feb 20, 2015 at 18:04
  • it's the actual drive local to the system the script is run on.
    – tlynnec
    Feb 20, 2015 at 18:06
  • Which account are you using to run the task? you user account or ???. Feb 20, 2015 at 18:09
  • I'm not sure what you mean by "the local user" exactly -- the account you're currently logged in as? When you setup the task you have to assign a user to it, just go look a the task's General tab to see which user is assigned to run the task... Feb 20, 2015 at 18:14
  • 1
    I would like to know why you don't want to keep a user logged in. I got a very similar situation in the past and resolved the problem by the combination of auto login and auto-locking (like Win-L). If you have a dedicated Windows account to perform this, everything will be fine.
    – Scott Rhee
    Mar 10, 2015 at 22:23

1 Answer 1


A GUI only app needs a desktop and you only get one of those when you're a logged in user.

But you may find some additional resources here: https://stackoverflow.com/questions/53232/how-can-i-run-a-windows-gui-application-on-as-a-service

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.