0

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
  • is E: available at startup or is this a user disk? enable the task history and see what it says (if it was run, was an error encountered,...)
    – Zina
    Commented Dec 10, 2020 at 10:48
  • @Zina , E: is available at startup. It's a hard disk partition. Commented Dec 10, 2020 at 11:34
  • 1
    yes, 1 is some error, I would use full paths for the commands you use (pushd & python - the path might not be active) and I always try not to use space characters in paths - maybe you need to enclose them between quotes. another thing you can do add some logging into a file (full path) into your script to see what works and what not and to test it faster you can try to run with time in future (a few mins) so you don't have to restart your computer for each test run
    – Zina
    Commented Dec 10, 2020 at 14:10
  • 1
    @AlphaDelta System shouldn't be used to execute an executable, as that then provides the executable System level permissions, which only a handful of executables should ever have, most dealing with VSS and system updating/servicing. Just an FYI for future reference, please include the XML output of the task (export the task and open in a text editor, pasting the content into a code box), as that allows for more efficient [faster] troubleshooting.
    – JW0914
    Commented Dec 12, 2020 at 1:23
  • 1
    @AlphaDelta you can post that as the answer down below to help others who may have the same issue. Commented Dec 15, 2020 at 4:48

2 Answers 2

1

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
  • 1
    Good. This is good for others with the same question, and for you because you'll get reputation score for this. Sweet, sweet reputation score. Commented Dec 16, 2020 at 0:38
0

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

1
  • 1
    Task Scheduler can run .bat files just fine without needing them to be packaged in an exe. It's possible you may wish to call command.com, but that shouldn't be necessary. As OP noted, they already solved the problem when they learned the User account running the task cannot be System. It can be helpful to read the comments on the question in order to avoid giving incorrect information. Commented Dec 15, 2020 at 4:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .