When you need to restart Windows Explorer it is quite cumbersome and error-prone to automate do this. That's why we have developed ShellDispenser-Dev; a small component that lets you restart Windows Explorer programmatically. You can do it with a single function call - even as an integrated step in your build environment or installation script!
The most obvious way to close Explorer programmatically is to call the Windows function TerminateProcess (or analoguous functionality). There are however some downsides to doing it this way.
Firstly, Explorer doesn't get the time to close gracefully this way. The result is that it cannot save it's settings, which in turn means e.g. the list of opened folders isn't retained.
Secondly, care must be taken the correct Explorer process is terminated. When multiple users are logged in, there will be as many Explorer.exe processes. And when (some) users have enabled the Explorer setting "Launch folder windows in a separate process", more than one Explorer.exe process may be running for that user. All of these processes must be closed first before Explorer can be restarted again normally.
Apart from this you can also restart Explorer manually. You can do this via Task Manager, but this equals to the above mentioned TerminateProcess method, with all it's shortcomings.
A somewhat better way to close Explorer on Windows 2000 and XP is by opening the "Turn off computer" window by clicking the "Start" button in the task bar and then selecting "Turn Off Computer". In this window simultaneously press the Control, Shift and Alt keys and click on "Cancel". Explorer will now close, which will result in an empty desktop.
For Windows Vista and Windows 7 the procedure is different; first you open the start menu, after which you keep the Ctrl and Shift keys pressed and simultaneously click on an empty spot in the lower left corner of the start menu with the right mouse button. A menu will appear from which you select the option "Exit Explorer".
This method will however only close the Explorer process that managed the desktop; when you have enabled the folder option "Launch folder options in a separate process" you still have to manually close the other Explorer process via Task Manager.
Apart from this, both methods are laborous and manual processes that cannot be automated.