How do I run a python script on behalf of the system in Windows 7.10?

There is a client-server application that should transmit data regardless of the login to the account (this is implemented in litemanager server) the user did not log in to the account, but the program is already working and gives a connection. I would like to implement the same....

Author: Иван, 2020-07-03

1 answers

Depending on what the script does, you can:

  1. package it into a service that should then be installed
  2. add it to the Windows registry (HKCU \ Software \ Microsoft \ Windows \ CurrentVersion \ Run)
  3. add a shortcut to it in the startup folder of the Start menu - its location may change depending on the OS version, but installers always have instructions for installing a shortcut to this folder
  4. use the Windows Task Scheduler, and then you can set a task for several types of events, including login and startup.

The actual solution depends on your needs and what the script actually does.

Some notes on the differences:

  • Solution # 1 runs the script from the computer, and solution # 2 and # 3 run it when the user who installed it logs in.
  • It's also worth noting that # 1 always runs the script, while # 2 and # 3 run the script is only for a specific user (I think if you use the default user, then it will run for everyone, but I'm not sure about the details).
  • Solution # 2 is a bit more "hidden" to the user, while solution # 3 leaves the user with much more control in terms of disabling auto-start.
  • Finally, solution # 1 requires administrative rights, while the other two can be executed by any user.
  • Decision No. 4 is something I've discovered recently, and it's very simple. The only problem I noticed is that the python script will cause a small command window to appear.

As you can see, it all comes down to what you want to do; for example, if it's something just for your purposes, I'd just drag it to the startup folder.

In any case, lately I've been relying on solution # 4 as the fastest and easiest approach.

 2
Author: Violet, 2020-07-05 10:15:32