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’.


Rodolfo Finochietti View All →

Uma's and Gino's father, and a programmer ;)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: