Jump to content

Host Name input for Dummies


Pook
 Share

Recommended Posts

Long story short: i have a script that creates a task based off the host name you input. (Easy right) We'll on of the support guys ran this script on a Production box. (Not good) I've been asked to make the script Dummy proof. All of the Production boxs start with PRO-XXXXX, and the Test boxs start with TST-XXXXXX.

My question is what does everyone think would be the best way to check if the name that was inputted doesn't start with "PRO-", and if it does I'm going to make it pop up a box saying. " Watch what your doing Dumb-A$$" =)

Link to comment
Share on other sites

Local $Hostname = InputBox("Input", "Host Name")
If StringInStr($Hostname, "PRO-") Then
    MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)")
    Exit
EndIf

Keep asking until not PRO-

While 1
    If CheckInput() <> 1 Then ExitLoop
WEnd

MsgBox(0, "Success", "String not PRO-")

Func CheckInput()
    Local $Hostname = InputBox("Input", "Host Name")
    If StringInStr($Hostname, "PRO-") Then
        MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)")
        Return 1
    EndIf
    Return 0
EndFunc

Or to Restart your program:

Local $Hostname = InputBox("Input", "Host Name")
If StringInStr($Hostname, "PRO-") Then
    MsgBox(0, "Error", "Watch what your doing Dumb-A$$ =)")
    _restart()
EndIf

; Restart your program
; Author UP_NORTH

Func _restart()
    If @Compiled = 1 Then
        Run( FileGetShortName(@ScriptFullPath))
    Else
        Run( FileGetShortName(@AutoItExe) & " " & FileGetShortName(@ScriptFullPath))
    EndIf
    Exit
EndFunc
Edited by rogue5099
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...