Thread: How can you start an application and automatically pass input to that application?

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    3

    How can you start an application and automatically pass input to that application?

    I want to create an application that starts an application and passes input to that application. I know how to start a process using the classes in System.Diagnostics, but I don't know how to pass data to the process.

    For example, and this is just an example, I would like to be able to automatically start an application that requires a username and password and automatically enter the username and password. Of course, that might open the door to security vulnerabilities, but that's not the point of the exercise.

    Can someone tell me how to implement the functionality I described?

    Is there a general way to go about doing this or does it depend entirely on the idiosyncrasies of the application in question?

  2. #2
    Registered User
    Join Date
    Mar 2009
    Location
    england
    Posts
    209
    There are two ways that immeditately spring to mind. First is to pass the arguments in the Process.Start, eg.

    Code:
    String name = "foo";
    String password = "bar";
    String args = "name=" + name + "&password=" + password;
    Process.Start("program.exe", args);
    Another way would be to use Process.Start to start the program and then use WCF to send the data as an IPC.

    This second method would be the most advantageous for many reasons. Cheifly the data you are passing between applications isn't limited to simple unencrypted strings. With named pipes you are sending byte arrays which can contain whatever you want.

    For more information on WCF named pipes see here System.IO.Pipes Namespace ()

  3. #3
    Registered User
    Join Date
    May 2012
    Location
    Bonn, Germany
    Posts
    16
    You might need to simulate key presses if the username/password can't be given to the program using command line arguments.
    Is this the case?

    ________________________________
    Visit my project: Derivative Calculator

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. start application
    By munna_dude in forum C Programming
    Replies: 4
    Last Post: 12-12-2006, 06:53 AM
  2. Application has failed to start?
    By VirtualAce in forum Game Programming
    Replies: 5
    Last Post: 05-08-2006, 12:30 PM
  3. This application failed to start... VS2005
    By Syneris in forum Windows Programming
    Replies: 3
    Last Post: 02-02-2006, 11:47 AM
  4. Pass Fake Keystrokes to 3'rd Party Application
    By Jattie in forum Windows Programming
    Replies: 11
    Last Post: 10-31-2002, 06:53 PM