473,382 Members | 1,437 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to pass cmdline args to a Windows App?

I have a simple one-form Windows App I'm working on in
VB. I need to be able to pass some command-line
parameters to the application in order for it to do what
it needs to do when it fires up.

Any pointers on how to do that?
Nov 20 '05 #1
5 1191
* "Tom Bower" <an*******@discussions.microsoft.com> scripsit:
I have a simple one-form Windows App I'm working on in
VB. I need to be able to pass some command-line
parameters to the application in order for it to do what
it needs to do when it fires up.


\\\
Public Sub Main(ByVal astrCmdLineArgs() As String)
Dim i As Integer
For i = 0 To astrCmdLineArgs.Length - 1
Console.WriteLine(astrCmdLineArgs(i))
Next i
End Sub
///

- or -

\\\
Public Sub Main()
Dim i As Integer
For i = 0 To Environment.GetCommandLineArgs().Length - 1
Console.WriteLine(Environment.GetCommandLineArgs(i ))
Next i
End Sub
///

In order to test the samples above, you must set the application's
startup object to 'Sub Main'. The 2nd sample code can be used at any
place inside a Windows Forms application too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Hey, that's cool, they're right there. And I even
figured out that you can pass sample ones using the
debugger by setting them in the Project's Debugging
Properties page.

Thanks, this forum is very helpful.
Nov 20 '05 #3
The 2nd sample code can be used at any
place inside a Windows Forms application too.


But it has the downside of requiring EnvironmentPermission read access
to the %PATH% variable, which might not be granted in a partially
trusted environment.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 20 '05 #4
You could Also use "microsoft.VisualBasic.Command"

Mike Bulava

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:u5**************@TK2MSFTNGP10.phx.gbl...
The 2nd sample code can be used at any
place inside a Windows Forms application too.


But it has the downside of requiring EnvironmentPermission read access
to the %PATH% variable, which might not be granted in a partially
trusted environment.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 20 '05 #5
* "Mike Bulava" <mb*****@comcast.net> scripsit:
You could Also use "microsoft.VisualBasic.Command"


'Microsoft.VisualBasic.Interaction.Command'.

;-)

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #6

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

Similar topics

2
by: leo | last post by:
hi there a python file can evaluate cmdline arguments like python myprog.py arg1 arg2 arg3... when i feed python with my program via terminal input like cat myprog.py | python
9
by: timothy.williams | last post by:
Hi. I trying to write an extension module to call some C libraries so I can use them in Python. Several of the library functions pass pointers to structures as arguments. I was thinking that I...
5
by: Didier C | last post by:
Hi! I was wondering if we can pass some arguments to system("cmdline")? E.g in Perl, we can do something like: $dir="/home/cypher"; system("ls $dir"); which would instruct Perl to do an...
0
by: Matt | last post by:
My problem is to allow ASP to interact with JSP, and I pass JavaScript object in my approach, but I wonder if it will work in network, not just in local machine. For testing purposes, the...
9
by: André | last post by:
Hi, How do I create an win 32 app and pass parameters to have it respond to the passed values? Like winzip "winzip32 -a" Kinda like Console args but I want to be able to call it via Start...
12
by: Huskier | last post by:
Hi all: I want to pass a class-member function to pthread_create, and my code is in the following, but I don't know how to pass myobj.thread_function to pthread_create function. #include...
2
by: SBh. via DotNetMonster.com | last post by:
I already created a windows service that receive parameter in Sub GetValue () and I can registered and started service successfully. But unfortunately, I don't know how to write program to call...
4
by: tony.ha | last post by:
Hello, I have open a Python program in the IDLE, but when I select the "run module" under "run" menu, it does not allow me to pass an argument to my Python program! How do you pass an argument...
3
by: swetha123 | last post by:
hello, I don't know how to use cookies please help me in this I am using the dream weaver cs4 I designed the navigation bar to my page using dream weaver cs4 navigation bar contains...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.