0

I already read up on the problem, that explorer tasks are behaving a little weird when more then one is opened, because I would have to remove the main explorer window if I wanted do remove a certain one.

I'm currently trying to achieve it like this, but it's obviously not working:

private Process explorerProcess = null;

private void startExplorer(){
    explorerProcess = Process.Start("explorer.exe", @*path*);
}

private void closeExplorer(){
    explorerProcess.Kill();
}

I also tried .Hide(), .Close() and so on but nothing seems to work. I don't want to loop all explorer processes and end them all, because when I want to get it done smoothly, not by closing all processes and letting the user notice it as soon as I kill the explorer.exe which is responsible for the start menu.

There must be any way I hope...

Sossenbinder
  • 4,852
  • 5
  • 35
  • 78
  • _Why_ would you want to kill arbitrary user processes? Can you explain your goal? Why is the code you show "obviously" not working? – CodeCaster Aug 17 '15 at 08:53
  • 1
    I would not suggest killing explorer.exe. Have you tried `Process.CloseMainWindow()` ? – bytecode77 Aug 17 '15 at 08:54
  • I don't want to kill that process. I want to open up a windows explorer instance for my users to browse and paste a file, and as soon as a button is pressed I want to close it again – Sossenbinder Aug 17 '15 at 08:54
  • @CodeCaster because he is the one creating it – Andrey Aug 17 '15 at 08:54
  • 3
    And you can't use a SaveFileDialog or something? – CodeCaster Aug 17 '15 at 08:55
  • 1
    You're confusing processes and windows, these are different concepts. Try looping through all windows (see http://stackoverflow.com/questions/27855828/get-process-handle-of-windows-explorer) and if you can find a way to idenfify which is yours, close only that window, by handle. – VoidStar Aug 17 '15 at 08:57

0 Answers0