Jump to content

Recommended Posts

Posted

Hello,

I have a gui that works great, however i am calling a function which includes an input box where i assign a variable and then pass it to a cmd. ( opens in a input window in addition to the mail gui )

My issue is that if I hit cancel or [x] in the input box or if the value is set to "" then the script continues, and i do not want it to.

I have tried to put an if then statement in there however the only success i have had killing it is to kill the main gui.

Here is a snipit of what i got:

Func rmcmd()
        Local $machinename = ""
        Local $machinename = InputBox("Hostname", "What is the hostname?", "", "", _
             -1, -1, 200, 200)
             If @error Then Exit
             Run("C:\WINDOWS\system32\cmd.exe")
                WinWaitActive("C:\WINDOWS\system32\cmd.exe")
                send("color D" & "{ENTER}")
                send("cd C:\pstools" & "{ENTER}")
                send("psexec \\" & $machinename & " cmd" & "{ENTER}")
                send("cls" & "{ENTER}")
EndFunc   ;==>Example

This works, BUT kills the entire gui not the input box. I have spent hours searching for a resolution for this with no avail. 

Note i just want to kill the input box without it continuing to the run portion as well

 

Thank You in Advance

 

  • Moderators
Posted

Just to confirm, if the user cancel the InputBox, or doesn't enter anything, you want do not want it to continue, but don't want it to kill the script, right? Something like this?

This will work whether they don't enter anything, hit the cancel button, or hit the x. The function will end, but not necessarily the whole script.

Func rmcmd()
 Local $machinename = InputBox("Hostname", "What is the hostname?", "", Default, Default, 200, 200)
  If $machinename <> "" Then
     ;The rest of your code
  Else
      MsgBox(0, "", "Error, cancelling") 
  EndIf
EndFunc

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted

 

Just to confirm, if the user cancel the InputBox, or doesn't enter anything, you want do not want it to continue, but don't want it to kill the script, right? Something like this?

This will work whether they don't enter anything, hit the cancel button, or hit the x. The function will end, but not necessarily the whole script.

Func rmcmd()
 Local $machinename = InputBox("Hostname", "What is the hostname?", "", Default, Default, 200, 200)
  If $machinename <> "" Then
     ;The rest of your code
  Else
      MsgBox(0, "", "Error, cancelling") 
  EndIf
EndFunc

 

YES, Thank you very much! I appreciate your assistance 

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
×
×
  • Create New...