|
-
Nov 14th, 2000, 08:28 AM
#1
Thread Starter
Lively Member
I would like to write a command line executable with multiple switches followed by user input(see below). Found several items in this column that have helped but none give any examples of multiple switches.
Would like user to be able to do this from the command line:
filename.exe -server <name> -start <web name> -kill <package> etc...
Any examples would be greatly appreciated!
-
Nov 14th, 2000, 09:49 AM
#2
Lively Member
Can't you just strip out the different switch's from command$ ?
Build this exe and then run it with switches like this "c:\project1.exe -server MINE -start www.home.com -kill vb.exe"
Code:
'' *put this in a module
Type switch_type
name As String
value As String
End Type
Public switch_def(3) As switch_type
'' *put this in the form load or in a button
' different switches user can pass
switch_def(1).name = "-server"
switch_def(2).name = "-start"
switch_def(3).name = "-kill"
Dim switch
switch = Command$
' for each possible switch that could be passed
For x = 1 To UBound(switch_def)
' if the user has used the switch
If InStr(switch, switch_def(x).name) > 0 Then
' get the value for the current switch
switch_def(x).value = Mid$(switch, InStr(switch, switch_def(x).name) + Len(switch_def(x).name), Len(switch))
If InStr(switch_def(x).value, "-") > 0 Then switch_def(x).value = Mid$(switch_def(x).value, 1, InStr(switch_def(x).value, "-") - 1)
' remove any spaces
switch_def(x).value = Trim(switch_def(x).value)
End If
Next x
' message box for each switch
For x = 1 To UBound(switch_def)
MsgBox "Switch Values" + vbNewLine + switch_def(x).name + " = " + switch_def(x).value
Next x
-
Nov 14th, 2000, 10:13 AM
#3
Thread Starter
Lively Member
Great example, thank you. Instead of writing output to a msgbox how would I output it back to the command line. This tool is going to be 100% command line driven.
-
Nov 14th, 2000, 10:22 AM
#4
Lively Member
What do you mean 'output it back to the command line' ?
You can use.. to run dos type commands....
-
Nov 14th, 2000, 11:13 AM
#5
Fanatic Member
Now how owuld you associate information in text boxes to the switches. Example lets say I had a form with text boxes that said server, start, etc. I then would want the input from the text boxes to be placed in the shell command with the exe.
-
Nov 14th, 2000, 11:26 AM
#6
Addicted Member
You can set up a default command in project properties. It just means you don't have to hard code any directories in, either that or just use variables.
"It wasn't the booze that made me snooze, It was the Gin that did me in!"
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|