Sign in to follow this  
Followers 0
pcjunki

func statement

8 posts in this topic

i'm getting an error on a new gui i'm making, but i dont know what to do

here is my code

i'm just at a loss and stumped

#include <GUIConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PSTOOL gui", 458, 290, 218, 329)
$Input1 = GUICtrlCreateInput("", 8, 40, 121, 21)
$Label2 = GUICtrlCreateLabel("username", 8, 80, 50, 17)
$Input2 = GUICtrlCreateInput("", 8, 96, 121, 21)
$Label3 = GUICtrlCreateLabel("pwd", 8, 136, 24, 17)
$Input3 = GUICtrlCreateInput("", 8, 152, 121, 21)
$Label4 = GUICtrlCreateLabel("Command", 8, 184, 51, 17)
$Input4 = GUICtrlCreateInput("", 8, 200, 409, 21)
$Button1 = GUICtrlCreateButton("GO", 8, 232, 75, 25)
$Label1 = GUICtrlCreateLabel("Computername", 8, 16, 75, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

Case $Button1
$pc = GUICtrlRead($input1)
$username = GUICtrlRead($input2)
$pwd = GUICtrlRead($input3)
$command = GUICtrlRead($input4)
call($pc,$username,$pwd,$command)

EndSwitch
WEnd
Func($pc)
ShellExecute("c:\pstools\psexec.exe", "\\" & $pc &" -u "& $username" -p "& $pwd" -c "& $command"")
EndFunc

Share this post


Link to post
Share on other sites



Can you post the error message you get?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Func($pc)

ShellExecute("c:pstoolspsexec.exe", "" & $pc &" -u "& $username" -p "& $pwd" -c "& $command"")

EndFunc

(33) : ==> Badly formatted "Func" statement.:

Share this post


Link to post
Share on other sites

The name of the function is missing.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

omg...how did i miss that...haha

no errors popping up now, but now when i click on "go" nothing happens

Share this post


Link to post
Share on other sites

This works fine for me:

#include <GUIConstants.au3>
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("PSTOOL gui", 458, 290, 218, 329)
$Input1 = GUICtrlCreateInput("", 8, 40, 121, 21)
$Label2 = GUICtrlCreateLabel("username", 8, 80, 50, 17)
$Input2 = GUICtrlCreateInput("", 8, 96, 121, 21)
$Label3 = GUICtrlCreateLabel("pwd", 8, 136, 24, 17)
$Input3 = GUICtrlCreateInput("", 8, 152, 121, 21)
$Label4 = GUICtrlCreateLabel("Command", 8, 184, 51, 17)
$Input4 = GUICtrlCreateInput("", 8, 200, 409, 21)
$Button1 = GUICtrlCreateButton("GO", 8, 232, 75, 25)
$Label1 = GUICtrlCreateLabel("Computername", 8, 16, 75, 17)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $pc = GUICtrlRead($Input1)
            $username = GUICtrlRead($Input2)
            $pwd = GUICtrlRead($Input3)
            $command = GUICtrlRead($Input4)
            PS($pc, $username, $pwd, $command)
    EndSwitch
WEnd

Func PS($pc, $username, $pwd, $command)
    MsgBox(0, "", "$pc: " & $pc & @CRLF & "$username: " & $username & @CRLF & "$pwd: " & $pwd & @CRLF & "$command: " & $command)
    ; ShellExecute("c:pstoolspsexec.exe", "" & $pc &" -u "& $username" -p "& $pwd" -c "& $command"")
EndFunc   ;==>PS

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

sweet, i got that working now with your modified code! woohoo

but now as i'm trying to get my line workin...i have "another" error

(36) : ==> Error in expression.:

ShellExecute("c:pstoolspsexec.exe", "" & $pc &" -u "& $username" -p "& $pwd" "& $command )

ShellExecute("c:pstoolspsexec.exe", ^ ERROR

i think i have to many quotes, or quotes in the wrong place somewhere

Share this post


Link to post
Share on other sites

No problem with quotes but with ampersands: two & were missing. Try:

ShellExecute("c:pstoolspsexec.exe", "" & $pc & " -u " & $username & " -p " & $pwd & " " & $command)

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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