Jump to content

Net.exe Script Issue


Recommended Posts

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

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 password

Actually - 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

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 by ClayB
Link to comment
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
 Share

  • Recently Browsing   0 members

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