0

I am trying to kill a task but in order to do it I need admin privileges. This is the code I am running

And so far I was not able to find a functional code that would bypass the need for admin. And when I found one than it was filled with errors or was made for python 2.

Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
golDer sk
  • 11
  • 2

1 Answers1

0

I was not able to find a functional code that would bypass the need for admin

Assuming that you have admin privileges on your system, you can run your script with evaluated privileges as detailed in this answer. Otherwise, aside from exploits specific to your version of Windows, it is not possible to "bypass" the need for admin.

As for not being able to use code written in Python 2, you can always convert code between between Python versions. This can be done manually or using an automated tool such as the standard 2to3 program that ships with CPython.

One other side note: the infinite loop in the sample of code that you posted would normally be written as

while True:
    #  body statements

Using 1 in place of True still works as non-zero integers are "truthy" when evaluated in a context where a boolean expression is expected.

Brian61354270
  • 8,690
  • 4
  • 21
  • 43
  • So what code would I use in my script to request the admin password without me having to manually run it as administrator? I done something like that using cmd but I am trying to recreate it in python. – golDer sk Mar 04 '19 at 09:12
  • While I have not had the opportunity to test it, [this answer](https://stackoverflow.com/a/41930586/11082165) to a similar SO question provides a short working example of what I believe you are looking for. You may also find some of the code in the responses to the SO question I linked in my answer helpful. – Brian61354270 Mar 04 '19 at 14:50
  • Well I have to thank you because it requests the admin rights as I wanted but the script closes immediately after I allow it to run under UAC and doesn't close the task. The problem isn't in my code that it is not able to close it, I tried it on tasks that don't need UAC but right after I press "Yes" (UAC) it closes the script. – golDer sk Mar 04 '19 at 18:58