usera Posted January 21, 2008 Share Posted January 21, 2008 Greeting, I create a sample file as following: (I am administrator on this box), the goal is get the net user information in notepad, Please let me know what is wrong, I use step by step in DOS it is ok. #include <Date.au3> #include <Inet.au3> $UserName= InputBox("User name", "Enter the user name:", "", "*", 300, 140) $Filename="C:\Userinfo.txt" shellexecute("Net.exe", '" User " & $UserName & " /Domain >>" & $FileName') shellexecute("notepad.exe", $FileName) ---------------------------------------------------------------------------------------------------------------------------- Thanks Link to comment Share on other sites More sharing options...
DW1 Posted January 21, 2008 Share Posted January 21, 2008 (edited) #include <Date.au3> #include <Inet.au3> $UserName= InputBox("User name", "Enter the user name:", "", "*", 300, 140) $Filename="C:\Userinfo.txt" RunWait(@ComSpec & " /c " & "net user " & $UserName & " > " & $FileName) shellexecute("notepad.exe", $FileName) EDIT: what you did wrong was: Shellexecute is the same as typing into the Start>Run dialog. RunWait(@ComSpec & " /c " & <commands>) Is the same as running in "Dos box" IE cmd.exe (From help file on Run or RunWait) Edited January 21, 2008 by danwilli AutoIt3 Online Help Link to comment Share on other sites More sharing options...
usera Posted January 21, 2008 Author Share Posted January 21, 2008 Thanks for your reply, I did change the code as you tell me. but for some reason, notepad give me nothing in the c:\userinfo.txt any advises? thanks #include <Date.au3> #include <Inet.au3> $UserName= InputBox("User name", "Enter the user name:", "", "*", 300, 140) $Filename="C:\Userinfo.txt" RunWait(@ComSpec & " /c " & "net user " & $UserName & " > " & $FileName) shellexecute("notepad.exe", $FileName) EDIT: what you did wrong was: Shellexecute is the same as typing into the Start>Run dialog. RunWait(@ComSpec & " /c " & <commands>) Is the same as running in "Dos box" IE cmd.exe (From help file on Run or RunWait) Link to comment Share on other sites More sharing options...
DW1 Posted January 21, 2008 Share Posted January 21, 2008 If nothing is in the userinfo.txt then the user does not exist (or is being typed incorrectly) I tested this on my XP box and a 2K3 server VM, both worked fine AutoIt3 Online Help Link to comment Share on other sites More sharing options...
usera Posted January 21, 2008 Author Share Posted January 21, 2008 you are right, it works now.Thank you very very much!Thanks for your reply, I did change the code as you tell me. but for some reason, notepad give me nothing in the c:\userinfo.txtany advises?thanks Link to comment Share on other sites More sharing options...
/dev/null Posted January 21, 2008 Share Posted January 21, 2008 If nothing is in the userinfo.txt then the user does not exist (or is being typed incorrectly)then you should have an error message in the text file!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
DW1 Posted January 21, 2008 Share Posted January 21, 2008 then you should have an error message in the text file!CheersKurtAfraid not.... with an invalid user, you would just get a blank txt file, no error. AutoIt3 Online Help Link to comment Share on other sites More sharing options...
/dev/null Posted January 21, 2008 Share Posted January 21, 2008 Afraid not.... with an invalid user, you would just get a blank txt file, no error.you're right. The command sends error messages to STDERR. net user nosuchuser /domain > out.txt 2>err.txterr.txt will contain the error message.CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
usera Posted January 21, 2008 Author Share Posted January 21, 2008 (edited) Any reason, I add /domain then I goto nothing in userinfo.txt? could you please help me try in domain environment?I did login in domain, before I am try that.thanksRunWait(@ComSpec & " /c " & "net user " & $UserName & " /domain> " & $FileName)Sic semper tyrannis*****Group: Full MembersPosts: 886Joined: 18-April 07From: Eugene, OR, USMember No.: 22,566 If nothing is in the userinfo.txt then the user does not exist (or is being typed incorrectly)I tested this on my XP box and a 2K3 server VM, both worked fine Edited January 21, 2008 by usera Link to comment Share on other sites More sharing options...
DW1 Posted January 21, 2008 Share Posted January 21, 2008 you're right. The command sends error messages to STDERR. net user nosuchuser /domain > out.txt 2>err.txterr.txt will contain the error message.CheersKurtHmmm... Did not know that you could do that.... thanks, that may come in useful in the future AutoIt3 Online Help Link to comment Share on other sites More sharing options...
/dev/null Posted January 21, 2008 Share Posted January 21, 2008 Any reason, I add /domain then I goto nothing in userinfo.txt? could you please help me try in domain environment?I did login in domain, before I am try that.thankswhat's the output of the command if you run it in a DOS box?CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
usera Posted January 21, 2008 Author Share Posted January 21, 2008 (edited) what's the output of the command if you run it in a DOS box?CheersKurtI got exactlly what I am looking for like:The request will be processed at a domain controller for domain av.opUser name useraFull Name useraComment userUser's comment Country code 000 (System Default)Account active YesAccount expires NeverPassword last set 11/5/2007 9:55 AMPassword expires 2/3/2008 9:55 AMPassword changeable 11/6/2007 9:55 AMPassword required YesUser may change password YesWorkstations allowed AllLogon script User profile Home directory \\rUsers\useraLast logon 1/21/2007 10:38 AMLogon hours allowed AllLocal Group Memberships Global Group memberships *Sales The command completed successfully.Update:it works if I use c:\userinfo.txt. but it NOT if I user @UserProfileDir for the file location, I think it may be long directory name issue. Edited January 21, 2008 by usera Link to comment Share on other sites More sharing options...
/dev/null Posted January 21, 2008 Share Posted January 21, 2008 I got exactlly what I am looking for like: assuming your code is O.K., you are probably not allowed to write to the file. Try this: #include <Constants.au3> $UserName= InputBox("User name", "Enter the user name:", "", "*", 300, 140) $pid= Run(@ComSpec & " /c net user " & $UserName & " /domain", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($pid) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($pid) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend Cheers Kurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
usera Posted January 21, 2008 Author Share Posted January 21, 2008 assuming your code is O.K., you are probably not allowed to write to the file. Try this: #include <Constants.au3> $UserName= InputBox("User name", "Enter the user name:", "", "*", 300, 140) $pid= Run(@ComSpec & " /c net user " & $UserName & " /domain", @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line = StdoutRead($pid) If @error Then ExitLoop MsgBox(0, "STDOUT read:", $line) Wend While 1 $line = StderrRead($pid) If @error Then ExitLoop MsgBox(0, "STDERR read:", $line) Wend Cheers Kurt Kurt, Your codes are perfect. it work, But I really want to put the out to the user profile folder. as I said before I am the administrator, I have rights, it may be "c:\documents and settings" and "C:\docume~1" issue thanks Link to comment Share on other sites More sharing options...
/dev/null Posted January 21, 2008 Share Posted January 21, 2008 Kurt,Your codes are perfect. it work, But I really want to put the out to the user profile folder. as I said before I am the administrator, I have rights, it may be "c:\documents and settings" and "C:\docume~1" issuethanksc:\documents and settings ?? O.K. I guess the assumption that your code is O.K. was simply wrong. Please post the EXACT code you are using!CheersKurt __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf * Link to comment Share on other sites More sharing options...
AlVanzoy Posted January 25, 2008 Share Posted January 25, 2008 Have you tried something liket this? RunWait(@ComSpec & " /c " & "net user " & $UserName & " > " & """" & @UserProfileDir & "\" & $FileName &"""") 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