metulburr
New Member
- Joined
- Mar 25, 2014
- Messages
- 5
- Thread Author
- #1
I am trying to elevate a command given (in this case just another cmd.exe) if the user is not admin. However i get the error:
this is a personal pc, and i know i put in the password correctly as i have done it a few times slowly typing in my admin password to confirm that it is input correctly. So why am i getting this error?
initially my overall goal is to get this python script to say you are admin
if you are admin its done, but if you are not admin then it reruns itself with the so called runas command to get admin rights. However currently it just pulls up the runas usage messages. The full command this script attempts to run then is:
Code:
C:\Users\metul_000>runas /user:administrator cmd.exe
Enter the password for administrator:
Attempting to start cmd.exe as user "WINDOWS8\administrator" ...
RUNAS ERROR: Unable to run - cmd.exe
1326: The user name or password is incorrect.
C:\Users\metul_000>
this is a personal pc, and i know i put in the password correctly as i have done it a few times slowly typing in my admin password to confirm that it is input correctly. So why am i getting this error?
initially my overall goal is to get this python script to say you are admin
Code:
import ctypes
import subprocess
import sys
import os
if os.name == 'nt':
if ctypes.windll.shell32.IsUserAnAdmin():
print('You are admin')
else:
print('You are not admin')
print('running as admin')
command = 'python3 {}'.format(sys.argv[0])
cmd = 'runas /user:administrator "{}"'.format(command)
subprocess.call(cmd.split())
Code:
C:\Users\metul_000>runas /user:administrator "python3 test2.py"
Enter the password for administrator:
Attempting to start python3 test2.py as user "WINDOWS8\administrator" ...
RUNAS ERROR: Unable to run - python3 test2.py
1326: The user name or password is incorrect.
C:\Users\metul_000>
Last edited: