By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Passing multiple (dynamic) external arguments to app

P: n/a
Greets all. I'm attempting to write an app that will be used as a
'control/launcher' application for other apps. For the sake of argument
let's say the app is launched from a command line:

controlapp externalapp argument1 argument2 argument3 argument4...etc.
(number of arguments is ALWAYS dynamic)

I'm been able to get the array passed properly, but ONLY when I know in
advance the amount of items in the array. I'm stuck on how to allow for
any amount of arguments.
Dim applaunch As Process = New Process()
Dim arrayCount As Integer, appArgs() As String

'pull external exe path/name and arguments into array, then count array
items
appArgs = System.Environment.GetCommandLineArgs
For arrayCount = 0 To UBound(appArgs)
Next arrayCount

'command line = controlapp externalapp argument1 argument2 argument3
'I start at 2nd item in array, as appargs(0) = controlapp
applaunch.StartInfo.FileName = appArgs(1)
applaunch.StartInfo.Arguments = appArgs(2) & " " & appArgs(3) & " " &
appArgs(4)
Hopefully this is enough of the code to figure out what my next step should
be. I'm learning as I go with vb.net, so if I missed an incredibly obvious
solution, please be gentle! Additionally, is this even a good way of doing
it? Thanks in advance!
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"pyrexia" <py*****@hotmail.com> wrote in message
news:uW**************@TK2MSFTNGP15.phx.gbl...
Greets all. I'm attempting to write an app that will be used as a
'control/launcher' application for other apps. For the sake of argument
let's say the app is launched from a command line:

controlapp externalapp argument1 argument2 argument3 argument4...etc.
(number of arguments is ALWAYS dynamic)

I'm been able to get the array passed properly, but ONLY when I know in
advance the amount of items in the array. I'm stuck on how to allow for
any amount of arguments.
Dim applaunch As Process = New Process()
Dim arrayCount As Integer, appArgs() As String

'pull external exe path/name and arguments into array, then count array
items
appArgs = System.Environment.GetCommandLineArgs ******** What does this loop do ? ************************ For arrayCount = 0 To UBound(appArgs) ********** why not add something in the loop like ***********************
applaunch.StartInfo.Arguments = applaunch.StartInfo.Arguments & "
" & appArgs(arrayCount)
*********************************************** Next arrayCount

'command line = controlapp externalapp argument1 argument2 argument3
'I start at 2nd item in array, as appargs(0) = controlapp
applaunch.StartInfo.FileName = appArgs(1)
applaunch.StartInfo.Arguments = appArgs(2) & " " & appArgs(3) & " " &
appArgs(4)
Hopefully this is enough of the code to figure out what my next step should be. I'm learning as I go with vb.net, so if I missed an incredibly obvious
solution, please be gentle! Additionally, is this even a good way of doing
it? Thanks in advance!

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.769 / Virus Database: 516 - Release Date: 9/25/2004
Nov 21 '05 #2

P: n/a
Pyrexia,

Probably will this do the Job for you.

\\\
Public Sub MySub(ByVal ParamArray Args() As String)
'....Args is just an array with unknow lenght of strings in this case
End sub
////

I hope this helps?

Cor

"pyrexia"
Greets all. I'm attempting to write an app that will be used as a
'control/launcher' application for other apps. For the sake of argument
let's say the app is launched from a command line:

controlapp externalapp argument1 argument2 argument3 argument4...etc.
(number of arguments is ALWAYS dynamic)

I'm been able to get the array passed properly, but ONLY when I know in
advance the amount of items in the array. I'm stuck on how to allow for
any amount of arguments.
Dim applaunch As Process = New Process()
Dim arrayCount As Integer, appArgs() As String

'pull external exe path/name and arguments into array, then count array
items
appArgs = System.Environment.GetCommandLineArgs
For arrayCount = 0 To UBound(appArgs)
Next arrayCount

'command line = controlapp externalapp argument1 argument2 argument3
'I start at 2nd item in array, as appargs(0) = controlapp
applaunch.StartInfo.FileName = appArgs(1)
applaunch.StartInfo.Arguments = appArgs(2) & " " & appArgs(3) & " " &
appArgs(4)
Hopefully this is enough of the code to figure out what my next step
should
be. I'm learning as I go with vb.net, so if I missed an incredibly obvious
solution, please be gentle! Additionally, is this even a good way of doing
it? Thanks in advance!

Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.