We help IT Professionals succeed at work.

Vb.net shortcut


I`m wondering if it's possible to use the RUN command in windows to launch my vb.net application but also to send commands to it before it opens,

Such as,


myapplication -search 14564

when my app opens it knows that there's a command and it needs to filter the results for 14564

would this be possible?
Watch Question

Have you tried to wrap the application path in double quotes then add the command?

"c:\temp\myapp.exe" -search 14564


Yes but my question was what do I need to add in my Vb.net Application for it to recognize -search 14564 as a command?

Sorry, misread the question.  Is this a console application or windows forms application?


windows forms application
In the load event for the form add a String array that looks for the Command Line Args.  Then verify it has "-search" in it, if so then pass the 3rd argument in the loop (your search criteria) into what ever function you use to search.  Your selecting the 3rd argument because when the app runs it see itself as an argument, then it sees -search then it will see the next value.  Also, double quotes are not required to run this from start>run

You'll want to include some error checking here too!

        Dim passedArgs() As String = Environment.GetCommandLineArgs

        If passedArgs.Contains("-search") Then
        End If

Open in new window

c:\temp\myapp.exe -search 14564

will pass 14564 into the search function in the code block above.