Solved

Finding My Documents

Posted on 2013-01-08
5
245 Views
Last Modified: 2013-01-09
How do I find the path to users my documents and use that in a bat file?

The users have the my documents folder in different locations, some on the local machine, some held in offline files on a server that hasn't been around for a long while, some in their profile path of the roaming profile and very few in the correct location on the server.

Now I know the my documents folder location is specified in the registry in
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders

But how do I get and use this value in a bat file to sort out all these users?

Regards
0
Comment
Question by:tetrauk
5 Comments
 
LVL 26

Expert Comment

by:pony10us
ID: 38757242
Is this for a domain or local account?  I would start by looking at the environment variable %HOMEPATH% and checking the Documents folder there.  

dir %homepath%\Documents
0
 
LVL 9

Expert Comment

by:dustock
ID: 38757261
This might if you want to go the route of reading the registry key
http://www.robvanderwoude.com/ntregquery.php
0
 
LVL 53

Accepted Solution

by:
Bill Prew earned 500 total points
ID: 38757586
Here's a small example of getting that value from the registry and placing in in a variable. Then you can use the variable as needed.

@echo off
setlocal

REM Define constants
set Key=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
set Value=Personal

REM Query the registry for the key and value we need
for /F "tokens=2*" %%A in ('reg query "%Key%" /V "%Value%" 2^>nul ^|find /I "REG_"') do call set MyDir=%%~B
ECHO "%MyDir%"

Open in new window

~bp
0
 
LVL 1

Author Closing Comment

by:tetrauk
ID: 38758530
billprew...I think I love you.
0
 
LVL 53

Expert Comment

by:Bill Prew
ID: 38758937
:-), thanks, glad that was helpful.

~bp
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You may have a outside contractor who comes in once a week or seasonal to do some work in your office but you only want to give him access to the programs and files he needs and keep privet all other documents and programs, can you do this on a loca…
When you try to share a printer , you may receive one of the following error messages. Error message when you use the Add Printer Wizard to share a printer: Windows could not share your printer. Operation could not be completed (Error 0x000006…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
This Micro Tutorial will teach you how to change your appearance and customize your Windows 7 interface to your unique preference. This will be demonstrated using Windows 7 operating system.

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now