ClayB Posted May 19, 2011 Share Posted May 19, 2011 So what I am trying to do is run net.exe to get some user information. My current problem is that I need the script to run net.exe from an elevated command prompt in order for it to return the information I want. Without elevation it just returns "members" which is not very helpful. Any help would be appreciated. Here is a snippet of what I have gotten so far. #include <file.au3> RunWait(@ComSpec & " /c " & "net user >> C:\Temp\LocUser.txt") RunWait(@ComSpec & " /c " & "net localgroup >> C:\Temp\LocGroup.txt") Local $arr[1] _FileReadToArray("c:\Temp\LocGroup.txt",$arr) _FileWriteFromArray("c:\Temp\FromArr.txt",$arr) ;this strips the * symbol from the search results returned above $temp = StringTrimLeft($arr[6],1) ;arr[6] is Administrators on my test machine RunWait(@ComSpec & " /c " & "net localgroup " & $temp & " >> C:\Temp\GroupUsers.txt") Link to comment Share on other sites More sharing options...
JohnOne Posted May 19, 2011 Share Posted May 19, 2011 Have you tried using #RequireAdmin directive? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
ibroadbent Posted May 20, 2011 Share Posted May 20, 2011 Use — RunAsWait — and supply admin credentials.from the Help File (use it, it's really good):RunAsWait ( "username", "domain", "password", logon_flag, "program" [, "workingdir" [, show_flag [, opt_flag ]]] )I used RunAsWait to do a similar thing - this line below adds the current user's domain account to the local Administrators group:RunAsWait("Administrator", @ComputerName, "***********", 0 , @ComSpec & " /c net localgroup administrators /ADD " & @LogonDomain & "\" & @UserName,"",@SW_HIDE)Using the local Administrator account, where ********** is the local admin passwordActually - I don't think you or I need to use - @ComSpec & " /c - in front of "net", because net.exe is an external command Link to comment Share on other sites More sharing options...
ClayB Posted May 20, 2011 Author Share Posted May 20, 2011 (edited) I am sorry I didn't mention it, I already tried as runaswait and got the same results but used a different flag than you have specified here. I will try it without the @Comspec as well (which I got from one of the help files). Thanks for the help. **Edit Also my spacing was a little different, not sure how important white space is with autoit. Edited May 20, 2011 by ClayB Link to comment Share on other sites More sharing options...
ClayB Posted May 20, 2011 Author Share Posted May 20, 2011 Works like a charm, not sure if it was the flag or what but it is working. Thanks again. Link to comment Share on other sites More sharing options...
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