.bat file help RRS feed

  • Question

  • im trying to write a batch file that will ask me to select which programs open (that way i can open up some of my most used programs, but not all of which i preloaded) so for instance it would ask:


    Choose which programs to run:


    np. . . . . . . Run notepad

    gc. . . . . . . Open Google Chrome

    itunes. . . . .Open iTunes


    then i would type which ones i would like to open. therefore, if i wanted to listen to music while browsing the internet i would type something simlilar to 

    gc, itunes

    and i could mix and match any of the three


    however, i am a little new to the command prompt and writing batch files. im guessing i need an if-then-else instance for this. but i wouldnt know how to tell the computer     if i type gc, start(path to google chrome application). how would i? 

    Saturday, March 12, 2011 5:28 PM

All replies

  • I wouldn't use .bat, I would use .vbs.  Copy and paste following into text file and change extension to .vbs



    Sub StartMenu()

    Notepad = "C:\Windows\System32\notepad.exe"
    GoogleChrome = "C:\PathToGoogleChrome\Chrome.exe"
    iTunes = "C:\PathToiTunes\iTunes.exe"

    Set wshShell = WScript.CreateObject ("WSCript.shell")

    Option1 = "1) Notepad"
    Option2 = "2) Google Chrome" 
    Option3 = "3) iTunes"
    QueryChoice = InputBox(Option1 & VbCrLf & VbCrLf & Option2 & VbCrLf & VbCrLf & Option3 & VbCrLf & VbCrLf & Option4 & VbCrLf & VbCrLf & "Choose which program to run: ","Program Picker","")

    Set objRegExp = New RegExp
         With objRegExp
             .Pattern = "[0-3]"
             .IgnoreCase = True
             .Global = True
         End With

    If QueryChoice = "" Then
     ElseIf objRegExp.Test(QueryChoice) Then
     Select Case QueryChoice
     Case 1
     wshShell.run Notepad
     Case 2
     wshShell.run GoogleChrome
     Case 3
     wshShell.run iTunes
     Case Else
     Wscript.echo "Invalid Selection..."
     End Select
    Wscript.echo "Invalid selection..."
    End if

    End Sub

    Thursday, April 14, 2011 8:22 PM