Search Unity

Close external process

Discussion in 'Scripting' started by S_P_S, Feb 11, 2016.

  1. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    Hello,

    I have a question:

    In my game I open the explorer.exe with:
    Code (CSharp):
    1.  
    2. private System.Diagnostics.Process ExplorerProcess;
    3.  
    4. void OpenExplorer(){
    5.  
    6. ExplorerProcess = System.Diagnostics.Process.Start("explorer.exe");
    7.  
    8. }
    9.  
    Now I want to close the explorer:

    Code (CSharp):
    1.        ExplorerProcess.CloseMainWindow();
    2.      
    I also tried:

    Code (CSharp):
    1.        ExplorerProcess.Kill();
    2.      
    But both won't work. What I want is that the explorer window I opened will be closed.
    I get the exception that the process has already been closed, but I definitvely don't call that in my code.
     
  2. gorbit99

    gorbit99

    Joined:
    Jul 14, 2015
    Posts:
    1,350
    Do you close the window manually?
     
  3. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    No, of course not. That explorer window is still open.
     
  4. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    anyone an idea?
     
  5. S_P_S

    S_P_S

    Joined:
    Feb 25, 2015
    Posts:
    91
    no one?