Sign in to follow this  
Followers 0
joos

$Cmdline and Select

5 posts in this topic

Seems like I am having a bad day.

This works to a point

I have a Func which is called first cmdlinecheck()

Inside the func I have

$Var = $Cmdline [1]

Select
    Case $Var = 
        MsgBox(0, "", "Just Plain - All good")
    Case $Var = "/Upgrade"
        MsgBox(0, "", "Upgrade Do the Upgrade")
    Case $Var = "/Uninstall"
        MsgBox(0, "", "Uninstall Do the Uninstall")
    Case Else
        MsgBox(0, "", "Hmm I don't this! " & "$cmdline is " & $Var )
EndSelect

This works if my command line is MyFile.exe "" or MyFile.exe "/Upgrade" Or MyFile.exe "/Uninstall" I would like it to work on the first command like this MyFile.exe if that is the command line without the "" then it should understand this. Am I asking too much ? :whistle: Can't find the one for pulling my hair out.

Thanks

Joos

Share this post


Link to post
Share on other sites



Hi,

Global $var
If $cmdline[0] > 0 Then $Var = $Cmdline [1]

Select
    Case $Var = ''
        MsgBox(0, "", "Just Plain - All good")
    Case $Var = "Upgrade"
        MsgBox(0, "", "Upgrade Do the Upgrade")
    Case $Var = "Uninstall"
        MsgBox(0, "", "Uninstall Do the Uninstall")
    Case Else
        MsgBox(0, "", "Hmm I don't this! " & "$cmdline is " & $Var )
EndSelect

So long,

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Seems like I am having a bad day.

This works to a point

I have a Func which is called first cmdlinecheck()

Inside the func I have

$Var = $Cmdline [1]

Select
    Case $Var = 
        MsgBox(0, "", "Just Plain - All good")
    Case $Var = "/Upgrade"
        MsgBox(0, "", "Upgrade Do the Upgrade")
    Case $Var = "/Uninstall"
        MsgBox(0, "", "Uninstall Do the Uninstall")
    Case Else
        MsgBox(0, "", "Hmm I don't this! " & "$cmdline is " & $Var )
EndSelect

This works if my command line is MyFile.exe "" or MyFile.exe "/Upgrade" Or MyFile.exe "/Uninstall" I would like it to work on the first command like this MyFile.exe if that is the command line without the "" then it should understand this. Am I asking too much ? :whistle: Can't find the one for pulling my hair out.

Thanks

Joos

If I'm understanding this correctly, you want to be able to catch when no command line parameters are used for another Case section. If that's the situation, I'd use a Case such as:

Select
    Case $CmdLine[0]=0
        MsgBox(0,"","No command line parameters used")
    Case $Cmdline[1]="/Upgrade"
        MsgBox(0, "Upgrade", "Do the Upgrade")
    Case $Cmdline[1]="/Uninstall"
        MsgBox(0, "Uninstall", "Do the Uninstall")
    Case Else
        MsgBox(0, "Error", $CmdLine &" is an invalid parameter.")
EndSelect

- MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup]

Share this post


Link to post
Share on other sites

Hi,

Global $var
If $cmdline[0] > 0 Then $Var = $Cmdline [1]

Select
    Case $Var = ''
        MsgBox(0, "", "Just Plain - All good")
    Case $Var = "Upgrade"
        MsgBox(0, "", "Upgrade Do the Upgrade")
    Case $Var = "Uninstall"
        MsgBox(0, "", "Uninstall Do the Uninstall")
    Case Else
        MsgBox(0, "", "Hmm I don't this! " & "$cmdline is " & $Var )
EndSelect

So long,

Mega

Share this post


Link to post
Share on other sites

Hi,

Global $var
If $cmdline[0] > 0 Then $Var = $Cmdline [1]

Select
    Case $Var = ''
        MsgBox(0, "", "Just Plain - All good")
    Case $Var = "Upgrade"
        MsgBox(0, "", "Upgrade Do the Upgrade")
    Case $Var = "Uninstall"
        MsgBox(0, "", "Uninstall Do the Uninstall")
    Case Else
        MsgBox(0, "", "Hmm I don't this! " & "$cmdline is " & $Var )
EndSelect

So long,

Mega

Thanks for this worked just as I needed it.

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