TLOlivier Posted November 3, 2015 Posted November 3, 2015 (edited) Hello everyone. I'm brand new to AutoIT.I wanted to create a script to open a command window as Administrator and then enter some commands into that window.I created the following script to run a test: ; Script Start - Add your code below here #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> RunAs("Administrator","Domain","AdminPassword",0,"cmd.exe") Local $hWnd = WinWait("Administrator: C:\Windows\system32\cmd.exe", "", 10) MsgBox($MB_SYSTEMMODAL, "", "Handle: " & $hWnd) WinActivate($hWnd) Send ("dir")The command window opens up, the message box prints the handle number and then nothing. The "dir" command does not get sent to the command window.What am I doing wrong? Thank you for helping! Edited November 3, 2015 by TLOlivier
Moderators JLogan3o13 Posted November 3, 2015 Moderators Posted November 3, 2015 Hi, @TLOlivier welcome to the forum. Can you please expand on what exactly you're trying to accomplish? You can do a RunAs, and do most anything you would be able to do from the command line, without actually opening a command window. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
TLOlivier Posted November 3, 2015 Author Posted November 3, 2015 I would like to run the following command to change the DNS setting on a computer: netsh interface ip set dns name="Local Area Connection" static 192.168.1.1If there is a quote in the command, do I do a double quote to get AutoIT to recognize the quote? Thank you!
jdelaney Posted November 4, 2015 Posted November 4, 2015 #RequireAdmin Run(@ComSpec & ' /c netsh interface ip set dns name="Local Area Connection" static 192.168.1.1') IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now