[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:
Antony Lesuisse 2014-11-18 23:27:48 +01:00
parent aa9eec3497
commit fb9794835b
2 changed files with 8 additions and 5 deletions

View File

@ -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:

View File

@ -139,10 +139,13 @@ else:
finally:
ws.CloseServiceHandle(srv)
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()
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