0

I have tried various solutions given in the links below to start, stop Windows Service (rabbitmq) in a PyTest without any admin rights prompt (so it can run continuously in a build server):

  1. os.system method --> The PyTest terminal asks for administrator password
  2. subprocess.run method --> I got Access Denied error message

Is it possible to start stop Windows service in the Pytest bypassing the admin rights? If yes, how can I do it?

Unknown
  • 327
  • 2
  • 9
  • If reducing the security is an option for you you might lower UAC settings: https://docs.microsoft.com/en-us/windows/security/threat-protection/security-policy-settings/user-account-control-behavior-of-the-elevation-prompt-for-administrators-in-admin-approval-mode – An-dir May 07 '22 at 11:06
  • If that were possible, it would be a major security problem. Your process needs admin rights to do this. – MrBean Bremen May 07 '22 at 11:10
  • I just need to restart the Windows service in Pytest without the need to enter password or administrator prompt. Can I do it in Python code? – Unknown May 07 '22 at 11:11
  • @MrBeanBremen you are right. I ignored that He wrote "without any admin rights". – An-dir May 07 '22 at 11:56
  • 1
    @Unknown You might use "sc sdset servicename" to change permissions. The SDDL you need for that is a bit difficult but well described for example here: http://woshub.com/set-permissions-on-windows-service/ – An-dir May 07 '22 at 11:58
  • 1
    @An-dir, can you provide a solution from the example you provided? – Unknown May 07 '22 at 14:29
  • 1
    To clarify - the solution provided by @An-dir is to grant your user more rights (and it _is_ the solution, not an example). To do this, you need administrator rights, of course - there is no way to do this with standard user rights, otherwise the whole notion of administrator rights would be pointless. – MrBean Bremen May 08 '22 at 07:28

0 Answers0