Reading Command line arguments in VB.NET

Nice clear entry at:

http://forum.codecall.net/visual-basic-tutorials/16661-reading-command-line-arguments-visual-basic-net.html

In Project > My Project > Publish > Options > Deployment
Uncheck “Use “.deploy” file extension

Now after publishing you will get the .exe file. If you create a shortcut to this .exe file you can add command line arguments to it as shown in the image below:

 Dim CommandLineArgs As System.Collections.ObjectModel.ReadOnlyCollection(Of String) = My.Application.CommandLineArgs

 

For i As Integer = 0 To CommandLineArgs.Count - 1
     MessageBox.Show(CommandLineArgs(i))
Next

There maybe reasons why you may not want to uncheck this. Namely:

http://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(MICROSOFT.VISUALSTUDIO.PUBLISH.CLICKONCEPROVIDER.DIALOG.OPTIONS);k(TargetFrameworkMoniker-%22.NETFRAMEWORK%2cVERSION%3dV4.0%22)&rd=true

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: