Finding the location of the current users "My Documents

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
ollie39
Newbie
Posts: 1
Joined: Wed Mar 24, 2004 5:56 pm
Location: Oxfordshire, England
Contact:

Finding the location of the current users "My Documents

Post by ollie39 » Wed Mar 24, 2004 6:02 pm

I've got some existing batch file utilities that run with documents and programs stored in subdirectories under the "My Documents" of the currently logged on user which I'm converting with Macro scheduler. (Note, this location is different under w98, w2k and wXP, or if the user doesn't have different profiles setup on their machine)

Usually I use the %userprofile% system variable to find out where this directory is. But that's not supported (yet ? :-) ) in Macro Scheduler. Any suggestions as to how I might find this location, in a generic fashion?

(I've thought about screen scraping the "cmd" window having run SET, but that can't possibly be the best way - can it??)

Thanks in advance

Lumumba

Post by Lumumba » Wed Mar 24, 2004 7:56 pm

Well that's a never ending story ... :?
Would make sense to be able to use standard environment variables, but, ... I don't know :cry:

Have a try, can't test it here ...
Run Program>cmd /c set > find "userprofile" > c:\env.txt
ReadLn>c:\env.txt,1,userprofile
Separate>userprofile,=,userprofile
MessageModal>%userprofile_2%

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Thu Mar 25, 2004 10:07 am

Use RegistryReadKey to read one of the following:

Get the user's "My Documents" folder location:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\DocFolderPaths\Username

(Replace Username with the user's username!)

For default paths see under:
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

e.g. for "My Documents":
HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal

e.g.

RegistryReadKey>HKEY_LOCAL_MACHINE,Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders,Personal,DocFolder
MJT Net Support
[email protected]

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts