How to find the path of the Desktop of any pc

Hi there

I need to write a VB application that retrieves a file from a folder located on the desktop of any 'machine' it runs on. How do I get hold of the path of that particular machine . eg. C:\Documents and Settings\Craigz\Desktop.
(But each user is different!)

Any ideas?
zimanvanstaalAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

supunrCommented:
HOWTO: Use the SHGetFolderPath Function from Visual Basic
http://support.microsoft.com/default.aspx?scid=KB;en-us;q252652
supunrCommented:
actually use the following link...

HOWTO: Automatically Delete an Icon or Folder from the Desktop
http://support.microsoft.com/default.aspx?scid=KB;en-us;q197425


Dim WSHShell as Object
dim DesktopPath as string

   Set WSHShell = WScript.CreateObject("WScript.Shell")
   DesktopPath = WSHShell.SpecialFolders("Desktop")
supunrCommented:
Dim WSHShell as Object
dim DesktopPath as string

  Set WSHShell = CreateObject("WScript.Shell")
  if (not WSHShell is nothing) then
      DesktopPath = WSHShell.SpecialFolders("Desktop")
  end if


 
The following special folders are available: (based on MSDN)

AllUsersDesktop
AllUsersStartMenu
AllUsersPrograms
AllUsersStartup
Desktop
Favorites
Fonts
MyDocuments
NetHood
PrintHood
Programs
Recent
SendTo
StartMenu
Startup
Templates

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

BrianGEFF719Commented:
just do envior$("Desktop")

supunrCommented:
BrianGEFF719,

environ$("Desktop") ' Note the spelling correction of the function.

does not return any value in my machine.  I run Win2K.  Do you know why that is.  It returns correctly for UserName, WinDir, Path.  I don't have the desktop defined in my environment variables which I checked with the System Properties.
BrianGEFF719Commented:
If you have the enviroment variable for your desktop defined it will work, but only under 9x, because of NT each user has a diff desktop, so you couldnt use that of course for NT.


-Brian
supunrCommented:
OK,  thanks.
zimanvanstaalAuthor Commented:
Thanks a lot!
zimanvanstaalAuthor Commented:
Just to confirm that this works like a charm!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.