Batch script not running at startup using Windows Task Scheduler

I have written a simple batch script [E:\Project Artemis\startup.bat] to start Python SimpleHTTPServer at startup of Windows 7, with the script working when I manually execute it, but after adding it to Task Scheduler to launch at system startup, it does not do so (Task Scheduler shows the process ran and it's status as ready)

@ECHO OFF
pushd E:\Project Artemis\Wave
python -m http.server
  • When I try to run it from Task Scheduler manually, the script does not work and History shows the task was completed with return code 1, meaning something went wrong, but provides no details:
    Screenshot2
    • Directory Project Artemis contains multiple files and I added E:\Project Artemis\ to the task's Start in(optional) parameter

How do I troubleshoot this and is there another way to start Python SimpleHTTPServer at startup?

10

2 Answers

Answering my own question for future readers as per suggestion of @music2myear.

enter image description here

As it is visible in the screenshot, I had set the user as SYSTEM to give the task high privilege. But due to some reason this interfered with the ability of the task to run and I am not sure why. Even if I were to run it from task scheduler window, it would not work.

However after fiddling around, I found that if the User Account to run the task is NOT set to SYSTEM, the task runs perfectly.

For example:

enter image description here

1

You'll want to create an .exe that opens the .bat, then pin the .exe to the Startup menu.

1

You Might Also Like