Erik. Posted June 16, 2007 Share Posted June 16, 2007 Hi, I want to write a simple program for a few dos commands. How to send a command to dos and get the valeu back in a msgbox? You do not see the dos box or anything that the user can see that dos is running... Is there a solution for? For people that think wrong things. It is not made for a hack or something, there is a command in dos where you can change all passwords on the computer and for people that do not know how to i would like to make a program... Hope someone can help me I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
star2 Posted June 16, 2007 Share Posted June 16, 2007 (edited) check this outhttp://www.autoitscript.com/forum/index.ph...4187&hl=dosor check the example from the same topic#include <GUIConstants.au3> #include <Constants.au3> #include <process.au3> $frmLog = GUICreate("Elkie Backup Logger", 474, 285, 193, 115) $cmdCollect = GUICtrlCreateButton("Do", 385, 20, 81, 41) $edit1 = GUICtrlCreateEdit("", 22, 21, 354, 243) GUICtrlSetData(-1, "Resault will be here") $cmdCancel = GUICtrlCreateButton("Exit", 385, 69, 81, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $cmdCollect CompileMe() Case $cmdCancel exit EndSwitch WEnd Func CompileMe() Local $i, $pid, $line = "" Local $foo[4] $foo[0] = "c:\*.*" For $i=0 To 0 $pid = run(@comspec & " /c dir " & $foo[0] ,"",@SW_SHOW , $STDOUT_CHILD) Do $line &= StdoutRead($pid) Until @error Next GUICtrlSetData($edit1,$line) EndFunc Edited June 16, 2007 by star2 [quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u] Link to comment Share on other sites More sharing options...
Gif Posted June 16, 2007 Share Posted June 16, 2007 (edited) Hi, I want to write a simple program for a few dos commands. How to send a command to dos and get the valeu back in a msgbox? You do not see the dos box or anything that the user can see that dos is running... Is there a solution for? For people that think wrong things. It is not made for a hack or something, there is a command in dos where you can change all passwords on the computer and for people that do not know how to i would like to make a program... Hope someone can help me use this: #include <Process.au3> $rc = _RunDos("start Http://www.autoitscript.com") the command is going to run but im not sure if it's going to show anything to a msgbox but you can run commands in DOS using this command... Edited June 16, 2007 by c4nm7 Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted June 16, 2007 Share Posted June 16, 2007 use this: #include <Process.au3> $rc = _RunDos("start Http://www.autoitscript.com") the command is going to run but im not sure if it's going to show anything to a msgbox but you can run commands in DOS using this command... I think he wants to write a dos program, not use existing commands My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
Gif Posted June 16, 2007 Share Posted June 16, 2007 I think he wants to write a dos program, not use existing commandsHow to send a command to doshm i think he wants to use the existing dos commands to a new program, like his own DOS but i will be using msods commands...this is also,what star2 postedif he was here he could answer us;;; Link to comment Share on other sites More sharing options...
Erik. Posted June 16, 2007 Author Share Posted June 16, 2007 (edited) Now i am here Ok i don't want tp write a dos program and not my own program for dos:P What i want to do is send whit auto it the command 'net user' Then you get alle users of that pc back. Then whit some other command you can change te password.. Want to write a program that can do it so noobs do not need to ask Zo i need so send something to dos but also get something back... When u do #include <Process.au3> $rc = _RunDos("net user") msgbox(0,"",$rc) i only get a 0 back and not other things i need Edited June 16, 2007 by Erik. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
BeardedBlunder Posted June 16, 2007 Share Posted June 16, 2007 personally i'd try something along the lines of: (mt syntax may suck, this is to give the idea) $rc = _RunDos("net user > @TEMPDIR\Output.txt") then read the file "Output.txt" that DOS will write to in the temp folder instead of the screen & base MsgBox off the content. don't forget to have the script delete the file afterwards lol Link to comment Share on other sites More sharing options...
Erik. Posted June 16, 2007 Author Share Posted June 16, 2007 $rc = _RunDos("net user > C:\Output.txt") $get = FileRead("C:\Output.txt") MsgBox(0,"",$get) Whit this it works. Is there a way to do it whitout make a file? I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
BeardedBlunder Posted June 16, 2007 Share Posted June 16, 2007 You could try reading stdout from the pid returned in $rc it's where most DOS commands write, just i've only just updated to a version that could see it & am therefore not up on how to use it. Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 16, 2007 Share Posted June 16, 2007 $rc = _RunDos("net user > C:\Output.txt") $get = FileRead("C:\Output.txt") MsgBox(0,"",$get) Whit this it works. Is there a way to do it whitout make a file? A demo using StdOutRead(): #include <constants.au3> $rc = Run(@ComSpec & " /c net user", @WorkingDir, @SW_HIDE, $STDOUT_CHILD) $StdOut = "" While ProcessExists($rc) If StdoutRead($rc, 0, 1) Then $StdOut &= StdoutRead($rc) WEnd MsgBox(64, "Results", $StdOut) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Erik. Posted June 17, 2007 Author Share Posted June 17, 2007 (edited) That works nice i made a form etc.. and trying to fix it. I hope it would be not to hard... I think the problem would be this: When u get the usernames you can do this: net user 'username' * you need to send this but then you need to send the password 2 times... how could you do that... it must be 1 thing not get the username and close it and then open it and type password... Edited June 17, 2007 by Erik. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
Erik. Posted June 17, 2007 Author Share Posted June 17, 2007 I am trying but it will be hard i think:P i never use dos in autoit For example: #include <constants.au3> $rc = Run(@ComSpec & " /c net user 'username here' *", @WorkingDir, @SW_HIDE, $STDOUT_CHILD) When you do that you will get a msgbox back whit the text that you need to enter a password,second password and then that the password was succesfull changed.. Now how to full in the password? When you do this: #include <constants.au3> $rc = Run(@ComSpec & " /c net user 'username here' * password here confirm here", @WorkingDir, @SW_HIDE, $STDOUT_CHILD) it does not work... i deleted the script i only need to explain this line.. I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
FreeFry Posted June 17, 2007 Share Posted June 17, 2007 Hmm, I'm not sure if you understand the syntax of the net user command To add a user called Test, with the password Password, you'd use this: Run(@ComSpec & " /c net user Test Password /add", @WorkingDir, @SW_HIDE) Link to comment Share on other sites More sharing options...
BeardedBlunder Posted June 17, 2007 Share Posted June 17, 2007 NET HELP SYNTAX explains the syntax usage in the help items and NET HELP USER explains the usage of NET USER in case you wern't already familliar with it looking at these items myself, it appears you don't need * if you supply the password * = prompt for it Link to comment Share on other sites More sharing options...
Erik. Posted June 17, 2007 Author Share Posted June 17, 2007 Hi, To change any password in the pc whit that command you need to type a * after the name and then press enter, it will ask for the new password.. Try it so you can see what i mean.. Press Start, then Run and type cmd You will get a black box and then type net user You will get all accounts on the computer For example: net user administrator * Then it ask for the new password. It ask to confirm the password... I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
BeardedBlunder Posted June 17, 2007 Share Posted June 17, 2007 try playing with StdinWrite should be able to send the * & the new pass using that, you may have to set a Sleep between Link to comment Share on other sites More sharing options...
Erik. Posted June 17, 2007 Author Share Posted June 17, 2007 Never used but i will try hope it works I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
FreeFry Posted June 18, 2007 Share Posted June 18, 2007 (edited) To change a password of an existing user with username Test: net user Test newpass Works for me, should also work for you. Edited June 18, 2007 by FreeFry Link to comment Share on other sites More sharing options...
Erik. Posted June 20, 2007 Author Share Posted June 20, 2007 mmm nice it works:D i hope it will work for everything... Thanks I little problem, hard to find and fix Link to comment Share on other sites More sharing options...
FreeFry Posted June 20, 2007 Share Posted June 20, 2007 Glad to be of help. 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