Open explorer window and wait for it to close

前端 未结 2 1724
半阙折子戏
半阙折子戏 2020-12-21 08:21

I have a program that is opening an explorer window to a certain folder but i want to perform an action right after the explorer window is closed, but if I use the following

2条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-21 08:55

    Cannot regenerate the error. Just tried this:

    Process.Start("explorer.exe", "D:\\").WaitForExit();
    

    and it blocks the current thread and waits until I close the explorer windows. Make sure that you're not executing the command on another thread than the one you want to block. Also make sure that you set every instance of a window to start a new instance of explorer.exe via importing below .reg file:

    Windows Registry Editor Version 5.00
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer]
    "DesktopProcess"=dword:00000001
    [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer]
    "DesktopProcess"=dword:00000001
    [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\BrowseNewProcess]
    "BrowseNewProcess"="Yes"
    [HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\BrowseNewProcess]
    "BrowseNewProcess"="Yes"
    

    You'll need to restart your computer for this to take effect.

提交回复
热议问题