How to read and set "My documents" directory from command line ?

C

Camille Petersen

How can I read the current value (=directory) of the WinXPs "My documents" system folder ?

If I type at the command prompt:

set

I get all environment variables listed but NOT the vaue of "My documents".
How can I list this value from the command line otherwise ?

How can I set this value (temporarily for only the current session!) to another value (say D:\mydata")
from the command line ?

Camille
 
P

Pegasus \(MVP\)

Camille Petersen said:
How can I read the current value (=directory) of the WinXPs "My documents"
system folder ?

If I type at the command prompt:

set

I get all environment variables listed but NOT the vaue of "My documents".
How can I list this value from the command line otherwise ?

How can I set this value (temporarily for only the current session!) to
another value (say D:\mydata")
from the command line ?

Camille

You could run this batch file to get "My Documents":
@echo off
regedit /E reg1.txt
"HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
type reg1.txt | find /i "Personal" > reg2.txt
for /F "tokens=2 delims==" %%a in (reg2.txt) do set MyDocs=%%~a
set MyDocs=%MyDocs:\\=\%
echo Location of "My Documents": %MyDocs%
 
C

createwindow

Hi,

The Env Var HOMEPATH=\Documents and Settings\<your_login_name> is
the first bit, append "\My Documents" and you have it!

This is a special shell folder. I recommend reading the value but not
changing it, as that can cause unwanted headaches. Your documents will
end up split over two physical locations. MS provide shell functions
for messing in this area. And Windows Shell Explorer will allow you to
safely "Move" My Documents to your D drive. Right click / Properties -
"Move..."

Hope that helps a little anyway.

CreateWindow
http://mymessagetaker.com
The while-you-were-out message program you have been looking for!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top