12 มีนาคม 2554 17:28
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
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?
14 เมษายน 2554 20:22
I wouldn't use .bat, I would use .vbs. Copy and paste following into text file and change extension to .vbs
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
.Pattern = "[0-3]"
.IgnoreCase = True
.Global = True
If QueryChoice = "" Then
ElseIf objRegExp.Test(QueryChoice) Then
Select Case QueryChoice
Wscript.echo "Invalid Selection..."
Wscript.echo "Invalid selection..."