none
A question about Process.Start() RRS feed

  • Question

  • There is a wacky thing,  if call below function, it works fine.

    Process.Start(localFileSpec); // localFileSpec is some specific file.

    But when call below codes, it does not work.

    Process process = new Process();

    process.StartInfo.FileName = appExe; // appExe is the executable software . 

    process.StartInfo.Arguments = arguments; // arguments is the specific file to open.

    process.StartInfo.WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

    process.Start();

     

    So I wonder the difference between these two ways? BTW, the executed software supports DDE .

    Tuesday, June 28, 2011 2:35 AM

Answers

  • If command line doesnot work then passing file to exe will not work, it is because you don't know how the exe accepts the parameters. You should just use the first method and relay on Windows file association to get the exe running.
    Kinect rocks !!
    • Marked as answer by Wozniak_dl Friday, July 1, 2011 12:40 AM
    Thursday, June 30, 2011 9:21 AM

All replies

  • Is it not launching the process by second method or the launched process is not working ?


    Kinect rocks !!
    Tuesday, June 28, 2011 7:00 AM
  • What is the exact value of localFileSpec when Process.Start(localFileSpec); is executed and what are the values of appExe and arguments for the second code? Also, does the Exe reside in your executing projects bin\debug or bin\release folder (depending on which mode you are executing)?

     


    Please mark this as answer or vote as helpful if it solved your problem
    Tuesday, June 28, 2011 8:24 AM
  • Try this:

    ProcessStartInfo startInfo=new ProcessStartInfo(executableName,arguments);
               
    Process startedProcess=Process.Start(startInfo);

    Tuesday, June 28, 2011 9:44 AM
  • It launches the process by second method, but does not open the specific file.

    Does it mean the executable software has some thing wrong with it?

    Wednesday, June 29, 2011 12:12 AM
  • first method:

    localFileSpec = @"E:\Radrive.dno";

    second method: 

     appExe = "RADExec.exe";

    arguments = @"E:\Radrive.dno";

     

    The Exe is another product which I don't have its source code.

    Wednesday, June 29, 2011 12:16 AM
  • still not work.
    Wednesday, June 29, 2011 12:19 AM
  • And it works as expected if you go into the command prompt and type "RADExec.exe E:\Radrive.dno" ?
    Please mark this as answer or vote as helpful if it solved your problem
    Wednesday, June 29, 2011 6:35 AM
  • Well when you call from the 1st method it calls ShellExecute which works on the file assosiation and runs the application. That means you should also be able to double click on the file and open the file in the software.

    Second method calls CreateProcess :: The process runs, which is the job of Process.Start the argument is also given to the target process but you need to know for sure the number of args it expects and how to pass them.

    You might want to try :

    StartInfo->UseShellExecute  = True ;


    Kinect rocks !!
    Wednesday, June 29, 2011 7:09 AM
  • I use command line "RADExec.exe E:\Radrive.dno", it still does not work, only open the exe without any file opened.
    Thursday, June 30, 2011 5:12 AM
  • Hi,

    If you could not open the file use the command line, I think the issue is related to the RADExec.exe assembly.

    You need to confirm with the vendor of this product whether it will receieve an argument to specify a file to open.


    Paul Zhou [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, June 30, 2011 8:58 AM
  • I try "StartInfo->UseShellExecute  = True ;" and still not work, I guess probably is RADExec.exe has something wrong with it.
    And I find the "folder options" of RADExec.exe are:
    Action: open
    Application used to perform action:
    C:\PROGRA~1\ROCKWE~2\DRIVET~1\RADExec.exe /dde %1
    Use DDE is checked
    DDE Message : [open("%1")]
    Application: RADExec
    Topic: System
    I can not insert picture so list the information here. Do you know how to add picture ?

    Thursday, June 30, 2011 8:59 AM
  • If command line doesnot work then passing file to exe will not work, it is because you don't know how the exe accepts the parameters. You should just use the first method and relay on Windows file association to get the exe running.
    Kinect rocks !!
    • Marked as answer by Wozniak_dl Friday, July 1, 2011 12:40 AM
    Thursday, June 30, 2011 9:21 AM
  • ok, I am agree with you, thank you.
    Friday, July 1, 2011 12:34 AM
  • Thank you Prateek, you replied in the thread very quickly.

    I will mark it as answer to close this thread, you deserve it.

     

    Friday, July 1, 2011 12:40 AM