Jump to content

func statement


pcjunki
 Share

Recommended Posts

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
Link to comment
Share on other sites

Can you post the error message you get?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

The name of the function is missing.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

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