I have a Python script that adds some text to the hosts
file which allows administrator access only. So, what I do is I first open cmd from the Start menu on Windows 7, and then right click and go to Run as Administrator.
That works well.
However, my intent is to have that Python script run as soon as Windows start.
If there was no protected hosts
file between, I would simply change the extension of the Python script from .py to .pyw and put the script in the Startup folder to have Windows execute it at startup, but in this case the script wouldn't run.
Anyone would suggest how I could do this?
Edits: The suggested duplicate doesn't solve my problem. If I point to the .py or the .pyw script in the Task Scheduler, nothing happens.
I think I should be pointing to a .cmd or a .bat file, but don't know what to write in such a file.
python script.py
in a.cmd
file or convert your script into a.exe
using py2exe