Jump to content

Recommended Posts

Posted (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 by TLOlivier
  • Moderators
Posted

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!

Posted

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!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...