The Python script does not work well being an nssm service

56 views Asked by At

I am writing a program for remote control my pc. I use Python and NSSM to package the script into the windows service. Rn i am trying to implement remote lock.

import ctypes
ctypes.windll.user32.LockWorkStation()

while(True):
    pass

I packed this code into a process. Process works, but my PC is still unlocked:( I don't got any errors or smth. With other tasks this method works correctly. My backlight now controlled by MQTT server.

I've tryed to change Log on settings (here), but nothing changes. But i still think that problem is here. Maybe it runs as idk "another user" who can't lock my Windows account? I don't want to use Task Scheduler because i dont want to see console (even using pyw the console appears for a couple of milliseconds and disappears. Some libs do that).

Or is there a more convenient way to hide the console? I like the way with the service because I can easily reload my script without using the task manager.

0

There are 0 answers