Sign in to follow this  
Followers 0
EndFunc

Infamous Dos output

6 posts in this topic

#1 ·  Posted (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 by EndFunc

EndFuncAutoIt is the shiznit. I love it.

Share this post


Link to post
Share on other sites



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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 by JdeB

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0