Sign in to follow this  
Followers 0
TLOlivier

Newbie needs help

4 posts in this topic

#1 ·  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

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.


When you're dead, you don't know you're dead - it's only difficult for those that know you. It's the same way when you're stupid...

My Scripts: SCCM UDFInclude Source with Compiled Script, Windows Firewall UDF

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

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  
Followers 0