Jump to content

error the directory name is invalid when I use runasset


Recommended Posts

I can do a runas using the OS and I can run the commands with out the runas in my script but I am unable to run the commands in my script with the runasset feature

I get a "unable to execute the command" "the directory name is invalid" I have tried all the different runas options 0 1 and 2 and I have tried it with several commands

#include <GUIConstants.au3>

;Generated with Form Designer preview

$Form1 = GUICreate("CSC Admin Launcher......or not", 576, 135, 192, 125, -1, BitOR($WS_EX_ACCEPTFILES,$WS_EX_TOPMOST));$WS_EX_TOOLWINDOW

;

$domain = GUICtrlCreateCombo("Colbys", 296, 20, 89, 21)

GUICtrlSetData(-1,"Local","Colbys")

$program = GUICtrlCreateCombo("Explorer", 416, 20, 145, 21)

GUICtrlSetData(-1,"Command|Control Panel|Internet Explorer|Other","Explorer")

GUICtrlCreateLabel("User", 8, 0, 43, 20)

GUICtrlCreateLabel("password", 160, 0, 48, 20)

GUICtrlCreateLabel("Domain", 296, 0, 43, 20)

GUICtrlCreateLabel("Program", 416, 0, 43, 20)

$username = GUICtrlCreateInput("", 8, 20, 121, 21, -1, $WS_EX_CLIENTEDGE)

$password = GUICtrlCreateInput("", 160, 20, 113, 21, $ES_PASSWORD,$WS_EX_CLIENTEDGE)

$oprogram = GUICtrlCreateInput("", 8, 56, 553, 21, -1, $WS_EX_CLIENTEDGE)

GUICtrlSetState(-1,$GUI_ACCEPTFILES)

$launch = GUICtrlCreateButton("Launch", 416, 88, 145, 25)

GUISetState()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $launch

$rusername = GUICtrlRead($username)

$rpassword = GUICtrlRead($password)

$rdomain = GUICtrlRead($domain)

$rprogram = GUICtrlRead($program)

$roprogram = GUICtrlRead($oprogram)

RunAsSet($rusername, $rdomain, $rpassword)

If $rprogram = "command" Then

Run(@ComSpec & " /c " & 'cmd', "")

If $rprogram = "explorer" Then

Run(@ComSpec & " /c " & 'explorer', "",@SW_Hide)

EndIf

RunAsSet()

EndSelect

WEnd

GUIDelete()

Exit

Link to comment
Share on other sites

This works for me

#include <GUIConstants.au3>
;Generated with Form Designer preview

$Form1 = GUICreate("CSC Admin Launcher......or not", 576, 135, 192, 125, -1, BitOR($WS_EX_ACCEPTFILES, $WS_EX_TOPMOST));$WS_EX_TOOLWINDOW
;

$domain = GUICtrlCreateCombo("Colbys", 296, 20, 89, 21)
GUICtrlSetData(-1, "Local|" & @ComputerName, "Colbys")
$program = GUICtrlCreateCombo("Explorer", 416, 20, 145, 21)
GUICtrlSetData(-1, "Command|Control Panel|Internet Explorer|Other", "Explorer")

GUICtrlCreateLabel("User", 8, 0, 43, 20)
GUICtrlCreateLabel("password", 160, 0, 48, 20)
GUICtrlCreateLabel("Domain", 296, 0, 43, 20)
GUICtrlCreateLabel("Program", 416, 0, 43, 20)
$username = GUICtrlCreateInput("", 8, 20, 121, 21, -1, $WS_EX_CLIENTEDGE)
$password = GUICtrlCreateInput("", 160, 20, 113, 21, $ES_PASSWORD, $WS_EX_CLIENTEDGE)
$oprogram = GUICtrlCreateInput("", 8, 56, 553, 21, -1, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_ACCEPTFILES)

$launch = GUICtrlCreateButton("Launch", 416, 88, 145, 25)
GUISetState()

While 1
    $msg = GUIGetMsg()
    
    
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $launch
            $rusername = GUICtrlRead($username)
            $rpassword = GUICtrlRead($password)
            $rdomain = GUICtrlRead($domain)
            $rprogram = GUICtrlRead($program)
            $roprogram = GUICtrlRead($oprogram)
            RunAsSet($rusername, $rdomain, $rpassword)
            Select
                Case $rprogram = "command"
                    Run(@ComSpec & ' /c "' & $rprogram & '"')
                Case $rprogram = "explorer"
                    Run(@ComSpec & " /c " & 'explorer', "", @SW_HIDE)
                Case Else
                ;
            EndSelect
            RunAsSet()
    EndSelect
    
WEnd
GUIDelete()

Exit
Edited by gafrost

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

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