Saturday, March 24, 2018

windows - batch file runs fine manually, but line that launches exe fails when batch run in task scheduler

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:





2012-01-10T09:42:01.9781872
DOMAIN\Administrator



2012-01-10T02:00:00
true





1





DOMAIN\Administrator
InteractiveToken
HighestAvailable




PT10M
PT1H
true
false

IgnoreNew
true
true
true
false
false
true
true
false
false
false
P3D
7

PT15M
3




E:\IISRESET+Optimize.bat
E:\Data\Optimize\



No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...