How to obtain the location of All Users Desktop Folder

.NET Framework provides the method System.Environment.GetFolderPath to obtain the location of some special folders. This method uses the enumeration System.Environment.SpecialFolder that doesn’t include a member for the All Users Desktop Folder. To find the location of the All Users Desktop folder we need to use the Windows Script Host in the following way:

using IWshRuntimeLibrary;



object allUsersDesktop = “AllUsersDesktop”;
WshShell shell = new WshShellClass( );
string shortcutPath = shell.SpecialFolders.Item( ref allUsersDesktop ).ToString( );

To use Windows Scripting Host from Visual Studio .NET right-click on the project name within the Solution Explorer, select ‘Add Reference’, select the ‘COM’ tab, find and select the ‘Windows Script Host Object Model’ in the listbox, click ‘Select’, and then click ‘OK’.