Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: relative path my documents  (Read 4309 times)

0 Members and 1 Guest are viewing this topic.

Bennieboj

    Topic Starter


    Rookie

  • time flies, ur the pilot
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 7
relative path my documents
« on: September 26, 2010, 04:29:27 AM »
Hello everyone,

First of all, this is my first post here, if this topic isn't in the correct place, simply tell me (or @mods: move it please)

The title may be misleading. I know there isn't a variable to "My documents".
That's why I need a way around it. Some of us know that the location of "My documents" is stored into the register:
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
more specific into the value "Personal"

Well using this I exported the key above (*\Shell Folders) into a .txt which works like a charm.
REG EXPORT "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" "test.txt"

The problem is that is shows all the values in "Shell Folders"
I only need the text after    "Personal"=  *Path I need*
then I could set in to a variable %MYDOCPATH% or something and I could use that into the bat I'm making to copy stuff into "My Documents"

Could anyone help me isolate the path (in a bat file) I need and find a way to set it as a variable.
Thanks in advance,
Kind regards,

Bennieboj   

ps: I using WinXP home edition atm but the registry key is the same on every Windows PC (2000, XP, Vista and Win7)

Salmon Trout

  • Guest
Re: relative path my documents
« Reply #1 on: September 26, 2010, 05:26:43 AM »
Don't bother using REQ EXPORT and a text file. For one thing, you need the batch to be on a writeable volume, and also you'd be creating filesystem clutter. Better to use REQ QUERY and parse the output with FOR /F

Code: [Select]
@echo off
for /f "tokens=1-2*" %%A in (' REG QUERY "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" ') do if "%%A"=="Personal" set MYDOCPATH=%%C
echo This user's document folder is: %MYDOCPATH%


As you can see, my name is Mike.

Windows 7

Code: [Select]
This user's document folder is: C:\Users\Mike\Documents
Windows XP

Code: [Select]
This user's document folder is: C:\Documents and Settings\Mike\My Documents

Bennieboj

    Topic Starter


    Rookie

  • time flies, ur the pilot
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 7
Re: relative path my documents
« Reply #2 on: September 26, 2010, 05:38:39 AM »
Thanks, this is exactly what I'm looking for. I don't completely understand the code you used, but it works  :)
I had already found that kind of code but it just din't work for me.
Once again, thanks a lot for the answer and the fast reply  :)
« Last Edit: September 26, 2010, 06:12:22 AM by Bennieboj »

Salmon Trout

  • Guest
Re: relative path my documents
« Reply #3 on: September 26, 2010, 05:56:57 AM »
No need to quote the answer just to say thanks, but glad it worked for you.