0
votes

I have task scheduled a batch file to run at midnight.

  • It has highest privileges,
  • It is ran as administrator with a stored password, independent of whether the user is logged in or not
  • The environment is set to windows 2012
  • The batch file's folder is used when launching.

Batch file location and start folder respectively:

c:\ip\ip1.bat
c:\ip\

Batch file contents:

taskkill /im python.exe /f >nul 2>&1
taskkill /im chrome.exe /f >nul 2>&1

timeout 5
netsh interface ipv4 add address "Ethernet" 104.122.112.106 255.255.255.0

timeout 5
::netsh interface ipv4 delete address "Ethernet" 104.122.112.106
netsh interface ipv4 delete address "Ethernet" 104.122.112.107
netsh interface ipv4 delete address "Ethernet" 104.122.112.108

timeout 40
start /min "" python.exe C:\Users\Administrator\Desktop\host\server2.py

timeout 10
start /min "" "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir="D:\chrome1" --js-flags="--expose-gc"

The above batch works perfectly if launched manually.

However, whenever the above file is launched by the task scheduler, it is being executed only partially.

What happens is that both python and chrome processes are killed but not restarted.

Nevertheless, the task scheduler reports that last run result was successful (0x0).

I highly appreciate your help and suggestions.

EDIT:

ACTUALLY, both processes are launched!

However they are ran in the background, that is, I see them in task manager but I cannot interact with them in any way.

1
No, that's not the case. Please see the edit...Anonymous
So does any open question remain?user6811411
Yes, they are supposed to be minimized to taskbar, but not run as background processes!Anonymous
So want the batch to run independently from a currently logged in user and at the same time have access from the currently logged in user. You've to choose to either have the cake or eat it.user6811411
Well, I am logging in as "administrator" user, and the process is also ran as "administrator" user. I can't see why this would be a limitation.Anonymous

1 Answers

0
votes

Setting option "Run only when user is logged on" actually solved the problem.

I've been trying to avoid using this option because I use RDP to connect to the server and it's not possible to stay connected 24/7. Nevertheless, when disconnecting my RDP session, the "administrator" user still remains logged and the task scheduler executes the program regardless.

Yet another problem remains, the start command ignores the /min switch, and the launched processes are not minimized to taskbar.

I have posted another question: Cmd start command ignores /min switch