Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Get users desktop location?
Message
 
To
22/06/2021 16:07:27
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01681485
Message ID:
01681542
Views:
44
>>>>John, I ran your code and it gave me a folder on the C drive. My desktop and all data is on my D drive.
>
>Ouch- that is potentially a very big problem!
>
>Can you do me a favour: on the same machine, type %userprofile% from Windows Start: what's the folder it takes you to? My expectation is that it should be the same as Getenv("userprofile") with your Desktop, Documents, AppData etc within. If not, then at this end we need to do some quick fixing!
>
>Which is why I keep coming to these forums- better to learn this from you than a customer whose system suddenly seems broken. ;-)

My %userprofile% is c:\Users\Jeff but that is meaningless, IMO. I try to keep nothing on my C drive other than applications. As part of my DR plan I always have a saved system image of my C drive on a USB drive that I can restore at will and not worry about losing data because the data is on my D drive and my OneDrive.

In Windows Explorer you can very easily locate special folders to any location which is what I have done. I've relocated a number of special folders like desktop, documents, music, pictures to my OneDrive account.

I think that the only way to get the true folder location for these special folders is to use the Windows "Shell". That's what Christian's solution uses and that's what my solution used even though they use it via different coding routes.

Also, because you might not have access to the Shell you can use something like this:
ssfDESKTOPDIRECTORY = 0x10
oShell = CreateObject("Shell.Application")
strDesktop = oShell.NameSpace(ssfDESKTOPDIRECTORY).Self.Path
?strDesktop
This uses the Shell as well, but a slightly different flavor than my Wscript.Shell

https://stackoverflow.com/questions/8051450/geting-special-folders-with-shell-application#8051758
https://docs.microsoft.com/en-us/previous-versions/tn-archive/ee176604(v=technet.10)?redirectedfrom=MSDN (for constants to special folders)
Previous
Reply
Map
View

Click here to load this message in the networking platform