Vb.net shortcut

Hi,

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,

START->RUN

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?
FCapoAsked:
Who is Participating?
 
dustockCommented:
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
            Search(passedArgs(2))
        End If

Open in new window


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

will pass 14564 into the search function in the code block above.
0
 
dustockCommented:
Have you tried to wrap the application path in double quotes then add the command?

"c:\temp\myapp.exe" -search 14564
0
 
FCapoAuthor Commented:
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?
0
 
dustockCommented:
Sorry, misread the question.  Is this a console application or windows forms application?
0
 
FCapoAuthor Commented:
windows forms application
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.