[FIX] windows ctrl-c from cmd as a non admin
return False when calling is_running_as_nt_service from a non adminstrator account.
This commit is contained in:
parent
aa9eec3497
commit
fb9794835b
|
@ -26,7 +26,7 @@ if os.name == 'posix':
|
|||
import resource
|
||||
else:
|
||||
# Windows shim
|
||||
signal.SIGHUP = 0
|
||||
signal.SIGHUP = -1
|
||||
|
||||
# Optional process names for workers
|
||||
try:
|
||||
|
|
|
@ -139,10 +139,13 @@ else:
|
|||
finally:
|
||||
ws.CloseServiceHandle(srv)
|
||||
|
||||
try:
|
||||
with close_srv(ws.OpenSCManager(None, None, ws.SC_MANAGER_ALL_ACCESS)) as hscm:
|
||||
with close_srv(wsu.SmartOpenService(hscm, nt_service_name, ws.SERVICE_ALL_ACCESS)) as hs:
|
||||
info = ws.QueryServiceStatusEx(hs)
|
||||
return info['ProcessId'] == getppid()
|
||||
except Exception:
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pprint import pprint as pp
|
||||
|
|
Loading…
Reference in New Issue