EndFunc Posted March 27, 2007 Share Posted March 27, 2007 (edited) I have been trying to produce a dos output to an edit box and it will just not display. Not even in a message box. I've read tons of examples but not help for adding users to a particular group. I call this func and it's not working for me. Anyone? Func AssignAdmin() If Not IsAdmin() Then MsgBox(16, $AppTitle, "You must have admin rights on this account to add a local admin account.") Else $AdminInput = InputBox($AppTitle, "Please enter the username to make local admin.", "", " M") $AdminOutput = Run(@ComSpec & " /c net localgroup administrators /add domain\" & $AdminInput, @SystemDir, @SW_HIDE) While 1 $line = StdoutRead($AdminOutput) MsgBox(0,0, $line) GUICtrlSetData($Console,$line) ExitLoop WEnd EndIf EndFunc Edited March 27, 2007 by EndFunc EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
SkinnyWhiteGuy Posted March 27, 2007 Share Posted March 27, 2007 That'd be because you left off some needed parameters from the Run command. run(@ComSpec & " /c net localgroup administrators /add domain\" & $AdminInput, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Make sure you also "include<constants.au3>" near the top, so the above will work and not give you undefined variable errors. Link to comment Share on other sites More sharing options...
EndFunc Posted March 27, 2007 Author Share Posted March 27, 2007 That'd be because you left off some needed parameters from the Run command. run(@ComSpec & " /c net localgroup administrators /add domain\" & $AdminInput, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Make sure you also "include<constants.au3>" near the top, so the above will work and not give you undefined variable errors. Thanks but its still not showing anything in the message box or the edit control. Any other ideas? EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
Developers Jos Posted March 27, 2007 Developers Share Posted March 27, 2007 (edited) I have been trying to produce a dos output to an edit box and it will just not display. Not even in a message box. I've read tons of examples but not help for adding users to a particular group. I call this func and it's not working for me. Anyone? Just a general remark: you test if the user doesn't have Administrator access to the OS, and when not try to add somebody to the Administrators group ? Func AssignAdmin() If Not IsAdmin() Then MsgBox(16, $AppTitle, "You must have admin rights on this account to add a local admin account.") Else $AdminInput = InputBox($AppTitle, "Please enter the username to make local admin.", "", " M") $AdminOutput = Run(@ComSpec & " /c net localgroup administrators /add domain\" & $AdminInput, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line &= StdoutRead($AdminOutput) If @error Then ExitLoop WEnd MsgBox(0, 0, $line) GUICtrlSetData($Console, $line) EndIf EndFunc ;==>AssignAdmin Edited March 27, 2007 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
EndFunc Posted March 27, 2007 Author Share Posted March 27, 2007 Just a general remark: you test if the user doesn't have Administrator access to the OS, and when not try to add somebody to the Administrators group ? Func AssignAdmin() If Not IsAdmin() Then MsgBox(16, $AppTitle, "You must have admin rights on this account to add a local admin account.") Else $AdminInput = InputBox($AppTitle, "Please enter the username to make local admin.", "", " M") $AdminOutput = Run(@ComSpec & " /c net localgroup administrators /add domain\" & $AdminInput, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $line &= StdoutRead($AdminOutput) If @error Then ExitLoop WEnd MsgBox(0, 0, $line) GUICtrlSetData($Console, $line) EndIf EndFunc ;==>AssignAdmin Well in some cases we grant temp admin rights to a user through active directory which is only for a short time. There several instances where it is given to them permanently by adding them to the local group but you have to be logged in as admin to do that by the normal means. so that is just to let you know before it is ran. But I see your point because the output(if i can get it to work) should tell you if iti is successful or access denied. I still need help though. EndFuncAutoIt is the shiznit. I love it. Link to comment Share on other sites More sharing options...
EndFunc Posted March 27, 2007 Author Share Posted March 27, 2007 it seems to be disappearing fast so it looks like it might work but why is it replacing the text instead of just displaying the output as it spits it out. I even tried adding & @CRLF to the end and didn't help. EndFuncAutoIt is the shiznit. I love it. 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