I am trying to run design a python script that runs AD Users and Computers (dsa.msc) as a seperate admin account that differs from my standard login account so that it has permission to change accounts. I ran the below code and get the following error:
"PsExec could not start \127.0.0.1: The system cannot find the file specified."
I tried adding an extra \ and it does not help. Any ideas as to where my error is? I couldnt find a question similar enough where the awnser fixed mine. Is there a better way to do that? I cannot run the whole script as the admin account as it would break in other locations of the script. Thanks!
import os
from easygui import *
#Sets Admin Credentials for every use
adminaccount = enterbox('Please enter you admin username:', 'Termination Requests')
adminpass = passwordbox('Please enter the password:', 'Termination Requests')
#Informs of steps to take, opens AD Users and Computers, and verifies steps taken for notes.
msgbox('Search AD for the User Accounts to be terminated, VPN Access, and PC Assignment.', 'Termination Requests')
os.system('"PsExec.exe \\127.0.0.1 -u Domain\%s -p %s -i dsa.msc')
ad = boolbox('Did the user have an AD Account?', 'Termination Requests')
Add two more backslashes. psexec.exe \\\\127.0.0.1
- backslash is an escape sequence in a Python string, so you need to escape every one with another backslash.