CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jun 2009
    Posts
    35

    Send the Arguments to the Exe

    Suppose I have two exes WindowsApplication1.exe WindowsApplication2.exe..On the form load of WindowsApplication2.exe,I m calling WindowsApplication1.exe & sending the command line arguements..I copy the WindowsApplication1.exe into the debug folder of WindowsApplication2.exe.

    WindowsApplication2.exe
    Code:
      Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Process.Start(Application.StartupPath & "\" & "WindowsApplication1.exe", "one" & "two")
        End Sub


    WindowsApplication1.exe
    Code:
     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            MsgBox(Command)
        End Sub

    On form load of WindowsApplication2.exe,WindowsApplication1.exe is started & arguments are sent.
    Now I want to check on form load of WindowsApplication2.exe,I do not want to start WindowsApplication1.exe, i just want to send the arguments to the WindowsApplication1.exe. Is is possible? To send the command line arguments to the ruunning exe.

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Send the Arguments to the Exe

    You cannot send a command line argument to an already executing EXE. However, what you can do is to use Inter-Process Communication using named pipes. This would be little difficult to understand if you are a beginner. Couple of articles that will help you understand how it is done in .NET can be found here:
    http://www.codeproject.com/KB/thread...ipespart1.aspx
    http://www.codeproject.com/KB/thread...ipespart2.aspx

    Is there anything special that you would want to achieve?

    There is one more easier way of doing this using files. From WindowsApplication2, you can create a file with the required messages/commands that you want to send to WindowsApplication1. And in WindowsApplication1, you will use a FileSystemWatcher component to poll the folder where the 2nd application is writing the file. Once the file is created, an event will fire in the FileSystemWatcher that you can handle and read the file and continue with the remaining process that you would want App1 to execute.

  3. #3
    Join Date
    Jun 2009
    Posts
    35

    Re: Send the Arguments to the Exe

    FileSystemWatcher component ??? Plz explain it in more detail with eg

  4. #4
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: Send the Arguments to the Exe

    Read the documentation on MSDN. I am not good at explaining and writing examples. There are hundreds of examples there all over the net and on msdn.

    FileSystemWatcher Class
    Creating FileSystemWatcher Component Instances
    How to: Create FileSystemWatcher Component Instances

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured