Windows – How to refresh the desktop without restarting explorer.exe

desktopwindows

I have enough knowledge about registry files that i know how and where to change the desktops location through a script.

I am looking for a way to "refresh" (update/reload/synchronize) the desktop once changes to the registry occur.

The solution needs to be done automatically, i.e. Ran from a script or program however I can not and will not want to kill the explorer.exe process as that harms more of the system than intended.

Notes related to answers, not question:

The F5 refresh Apparently works but I have so far been able to get it to work with an autoit script. The issue was i was changing an environment variable value which was just a default location of it, and did not utilize the windows api of SHSetKnownFolder. I need to figure out how to get this function inside my batch/vbs scripts.

If you believe Killing the explorer.exe forcefully does not harm the computer, i can accept that if the fact that the amount of time needed to reboot it far outweighs the basic method of changing the desktop location through the user interface.

The thing may be intentionally looking for is a windows powershell cmdlett, that requires api call SHSetKnownFolderPath.

The thing that i want to happen is what occurs at the end of this video but from a batch or vbs script.

Best Answer

To refresh the content of the desktop (for example after changing its location) simply click on an empty section and press F5.

This only works when handling API calls that are maintained by the Explorer.exe process, which is why you originally discovered killing the Explorer.exe process did what you need in the first place.

Yes, you could change the registry value of the desktop, but because you didn't do it through normal or correct means, the typical F5 refresh didn't work.
Other scenarios where you may have encountered issues for example, if the network connection is lost while the actual desktop path has not changed, Explorer will give an error that the location is no longer accessible. If the network is restored, Explorer will simply not update.

In your case, the SHSetKnownFolderPath which you discovered with autoit (which is also a C++ script for Windows), performs the method correctly allowing you to click the desktop and press F5, issuing a refresh which is given the ability to update thanks to the API.

Related Question