Jump to content
Sign in to follow this  
TLOlivier

Newbie needs help

Recommended Posts

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 by TLOlivier

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.1

If there is a quote in the command, do I do a double quote to get AutoIT to recognize the quote?

 

Thank you!

Share this post


Link to post
Share on other sites
#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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...