python3管理员身份调用程序,如何以管理员身份运行命令/脚本?

Hello,

I want to run a script called scan.py in my Command terminal. I type inpython scan.py. I got told, since this is not working, to open the CMD window as admin. So the window shows me C:\Windows\system32>.

So my question is, how do I run my script from there, without having to type in the path to the script.

What I have tried:

(I tried that and it would run as a normal user again, not as admin) Should I move the file in to the directory system32?

Running "runas /user:administrator C:\users....\scan.py asks me for the password of the admin, but all of my suggestions were (I tried my own password and just hitting enter, both didn't work) wrong.

解决方案By default, when you open a command prompt as an administrator, the current directory is set to C:\Windows\System32.

You just have to navigate to the directory (cd path\to\your\py\file)

你可能感兴趣的:(python3管理员身份调用程序,如何以管理员身份运行命令/脚本?)