473,471 Members | 1,713 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Implement Command Line Variables

Hello,

I was wondering if anyone knows how to parse command line variables upon
execution of an application. For example, I want to be able to type this
at a command line: "myapp.exe /cid:12353" and have "myapp.exe" open and
display a record for a client with the id of 12353.

Does anyone know how to do that. Currently I have a text box on my form
that if I enter 12353 and hit enter, the record will appear. I want this to
be possible through a command line however.

Thanks in advance.
Nov 21 '05 #1
5 1099
You can use the System.Environment.GetCommandLineArgs method to retrieve the
command line arguments in the form of an array of strings. The First
argument is the full path of your application executable
(GetCommandLineArgs(0)) - the remaining will be the arguments that you
provide on the command line. Then you can use various string functions to
retrieve the relevant values from the arguments. For instance, for the
argument that you've mentioned, you could do something like this (watch for
typos - typed directly here):

Dim arg1 As String = _
System.Environment.GetCommandLineArgs(1)

Dim ID As Integer = Integer.Parse( _
arg1.SubString(arg0.IndexOf("/cid:") + 1))

This will give you the customer ID 12353.

hope that helps..
Imran.

"Stewart Saathoff" <sd********@hotmail.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hello,

I was wondering if anyone knows how to parse command line variables upon
execution of an application. For example, I want to be able to type this
at a command line: "myapp.exe /cid:12353" and have "myapp.exe" open and
display a record for a client with the id of 12353.

Does anyone know how to do that. Currently I have a text box on my form
that if I enter 12353 and hit enter, the record will appear. I want this
to be possible through a command line however.

Thanks in advance.

Nov 21 '05 #2
"Stewart Saathoff" <sd********@hotmail.com> schrieb:
execution of an application. For example, I want to be able
to type this at a command line: "myapp.exe /cid:12353" and have
"myapp.exe" open and display a record for a client with the id
of 12353.


\\\
Public Module Program
Public Sub Main(ByVal Args() As String)
If Args.Length > 0 Then

' 'Args' is a string array that contains the command line
' parameters' values.
End If
End Sub
End Module
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 21 '05 #3
Could you explain what you have put here?

Stewart
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:Oe**************@TK2MSFTNGP15.phx.gbl...
"Stewart Saathoff" <sd********@hotmail.com> schrieb:
execution of an application. For example, I want to be able
to type this at a command line: "myapp.exe /cid:12353" and have
"myapp.exe" open and display a record for a client with the id
of 12353.


\\\
Public Module Program
Public Sub Main(ByVal Args() As String)
If Args.Length > 0 Then

' 'Args' is a string array that contains the command line
' parameters' values.
End If
End Sub
End Module
///

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 21 '05 #4
I get a message that states "Input string in invalid format." Do you know
what causes that?
"Imran Koradia" <no****@microsoft.com> wrote in message
news:Os**************@TK2MSFTNGP11.phx.gbl...
You can use the System.Environment.GetCommandLineArgs method to retrieve
the command line arguments in the form of an array of strings. The First
argument is the full path of your application executable
(GetCommandLineArgs(0)) - the remaining will be the arguments that you
provide on the command line. Then you can use various string functions to
retrieve the relevant values from the arguments. For instance, for the
argument that you've mentioned, you could do something like this (watch
for typos - typed directly here):

Dim arg1 As String = _
System.Environment.GetCommandLineArgs(1)

Dim ID As Integer = Integer.Parse( _
arg1.SubString(arg0.IndexOf("/cid:") + 1))

This will give you the customer ID 12353.

hope that helps..
Imran.

"Stewart Saathoff" <sd********@hotmail.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hello,

I was wondering if anyone knows how to parse command line variables upon
execution of an application. For example, I want to be able to type
this at a command line: "myapp.exe /cid:12353" and have "myapp.exe" open
and display a record for a client with the id of 12353.

Does anyone know how to do that. Currently I have a text box on my form
that if I enter 12353 and hit enter, the record will appear. I want this
to be possible through a command line however.

Thanks in advance.


Nov 21 '05 #5
probably this:
arg1.SubString(arg0.IndexOf("/cid:") + 1))

Should be:
arg1.SubString(arg1.IndexOf("/cid:") + 1))

Rinze

Stewart Saathoff wrote:
I get a message that states "Input string in invalid format." Do you know
what causes that?
"Imran Koradia" <no****@microsoft.com> wrote in message
news:Os**************@TK2MSFTNGP11.phx.gbl...
You can use the System.Environment.GetCommandLineArgs method to retrieve
the command line arguments in the form of an array of strings. The First
argument is the full path of your application executable
(GetCommandLineArgs(0)) - the remaining will be the arguments that you
provide on the command line. Then you can use various string functions to
retrieve the relevant values from the arguments. For instance, for the
argument that you've mentioned, you could do something like this (watch
for typos - typed directly here):

Dim arg1 As String = _
System.Environment.GetCommandLineArgs(1)

Dim ID As Integer = Integer.Parse( _
arg1.SubString(arg0.IndexOf("/cid:") + 1))

This will give you the customer ID 12353.

hope that helps..
Imran.

"Stewart Saathoff" <sd********@hotmail.com> wrote in message
news:eA**************@TK2MSFTNGP10.phx.gbl...
Hello,

I was wondering if anyone knows how to parse command line variables upon
execution of an application. For example, I want to be able to type
this at a command line: "myapp.exe /cid:12353" and have "myapp.exe" open
and display a record for a client with the id of 12353.

Does anyone know how to do that. Currently I have a text box on my form
that if I enter 12353 and hit enter, the record will appear. I want this
to be possible through a command line however.

Thanks in advance.



Nov 21 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robert | last post by:
I am using the php4-cgi Debian package which is based on PHP 4.3.4. I have problems when running php4 on the command line. If I say something like $ php4 index.cgi a number of variables...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
6
by: Edd Dawson | last post by:
Hi. I have a strange problem involving the passing of command line arguments to a C program I'm writing. I tried posting this in comp.programming yesterday but someone kindly suggested that I'd...
5
by: clsmith66 | last post by:
I've been asked to find out if a project is possible, but I'm not having much luck finding the information I need, I hope some one can help. I need to see if I can build a windows service on the...
10
by: jimmy | last post by:
Hi again, sorry for posting two questions so close together but im working on a school project which is due in soon and running into some difficulties implementing the database parts. I have the...
9
by: Endless Story | last post by:
My last version of Python was 2.4, running smoothly on XP with path c: \Python24 - no need even to include this path in PATH; everything worked as it's supposed to at the command line. Just...
1
by: Dave Programmer | last post by:
In a Makefile, I have something like the following: # makefile start X = "default_x" Y = "default_y" targA: dosomething -x $(X) -y $(Y)
5
by: waltbrad | last post by:
Hi folks. I'm learning Python from the Mark Lutz Book, Programming Python 3rd edition. He seems to be able to invoke the Python interpreter from any command line prompt. C:\temp>python ...
3
by: smitty1e | last post by:
Just a fun exercise to unify some of the major input methods for a script into a single dictionary. Here is the output, given a gr.conf file in the same directory with the contents stated below: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.