0

I have a script which needs to run a command on command line with admin privileges.

password = "abcdef"
cmd = ['runas', '/user:', 'cmd.exe /C echo test']
cmd[1]+=str(platform.node())
subprocess.Popen(cmd)

I can have the code get to ask for password(admin password), but is there a way I can supply password without it asking me again and again as there a quiet a number of times I need to call command line

Harwee
  • 1,601
  • 2
  • 21
  • 35
  • http://www.guidingtech.com/4862/always-run-as-administrator/ – user1767754 Nov 11 '15 at 21:03
  • @user1767754 i can do it on my pc but what if I want to distribute this piece of code and there are people out there who don't know to change name of file – Harwee Nov 11 '15 at 21:09
  • Take a look at this answer: http://stackoverflow.com/questions/19672352/how-to-run-python-script-with-elevated-privilege-on-windows – kponz Nov 11 '15 at 22:50

0 Answers0