Solved

Pass command-line arguments to already running application

Posted on 2010-08-24
3
403 Views
Last Modified: 2012-05-10
I know how to parse through the command line arguments passed to the application when it was originally opened. Is it possible to pass more arguments to the application after it has already been opened? The app I am running is a single instance application and I was hoping to be able to pass them in the MyApplication_StartupNextInstance subroutine but can't seem to grab the new command-line parameters. Thanks.
0
Comment
Question by:rbichon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 33515740
Sure....you're using "e.CommandLine" in the StartupNextInstance() event right?
Namespace My

    ' The following events are available for MyApplication:
    ' 
    ' Startup: Raised when the application starts, before the startup form is created.
    ' Shutdown: Raised after all application forms are closed.  This event is not raised if the application terminates abnormally.
    ' UnhandledException: Raised if the application encounters an unhandled exception.
    ' StartupNextInstance: Raised when launching a single-instance application and the application is already active. 
    ' NetworkAvailabilityChanged: Raised when the network connection is connected or disconnected.
    Partial Friend Class MyApplication

        Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, ByVal e As Microsoft.VisualBasic.ApplicationServices.StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
            Dim args As New List(Of String)
            args.AddRange(e.CommandLine.ToArray())

            ' ... use "args" somehow ...

        End Sub

    End Class


End Namespace

Open in new window

0
 
LVL 1

Author Comment

by:rbichon
ID: 33515761
Nope. That was it! Thanks!!
0
 
LVL 85

Expert Comment

by:Mike Tomlinson
ID: 33515769
*Just FYI, "Environment.CommandLine" ALWAYS gets the args from when the process was STARTED:
http://msdn.microsoft.com/en-us/library/system.environment.commandline.aspx

    "This property provides access to the program name and any arguments specified on the command line when the current process was started."
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question