Anonymous
Anonymous

Reputation: 4630

Cmd batch file executes only partly when using task scheduler

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

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.

Upvotes: 0

Views: 365

Answers (1)

Anonymous
Anonymous

Reputation: 4630

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

Upvotes: 0

Related Questions