I am trying to write a program in python that consists of several parts:
- a config utility
- a hardware monitor
- a background process
The idea being that once installed (using cx_freeze) the hardware monitor is constantly running in the background, when a piece of compatible hardware (using d2xx driver for FTDI devices) is connected it checks the registry to see if it has been previously configured, if it has then it starts the background process with the serial number as an argument, however if not it starts the config utility.
However the hardware monitor needs to be running from start-up and as it only reads from the registry doesn't need full admin privileges, and the background process only reads so also does not need admin provileges, but the config utility needs to be able to write to the registry and hence needs admin.
My question is this: How can I call another program from within python as admin and with arguments?
I considered using os.startfile as I have set the frozen program as needing admin, however i then can't pass arguments to it.
I also considered using subprocess.Popen but i can't work out how, or even if you can, elevate this to admin level, so while it will open the program and pass it the arguments it can't write to the registry.
Any help would be appreciated, for further information my set-up is:
- Windows 7 64 bit (but also plan to do XP 32 bit)
- python2.7.6 (again 64 bit but plan to also do 32 bit)
- PyUSB-1.6
- psutil-1.2.1
- cx_freeze-4.3.2
Thanks
James