Jump to content

%My Documents%?


Recommended Posts


Here's how to do with a batch file :

@echo off

verify other 2>nul

setlocal enableextensions

if errorlevel 1 (echo error : setlocal failed&goto :eof)

rem TAKE CARE : the whitespace after delims= is ONE TAB plus ONE SPACE, in that order, and there is only one line until the next green text

for /f "skip=4 tokens=1,2,* delims= " %%l in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v "Personal"') do (set MyDocs=%%n)

rem do something with that value HERE and not elsewhere

rem for example :

copy c:\windows\winamp.ini "%MyDocs%\winamp_backup.ini"

echo Winamp.ini saved into %MyDocs%

rem since i used setlocal to enable the "command extensions", all env vars are local to this batch

rem so they will be deleted when the batch ends, or when the endlocal command is called

rem the two next lines show you the problem : "MyDocs" is now empty...

endlocal

echo MyDocs=%MyDocs%

:eof

Link to comment
Share on other sites

I find the Shell Folders key more successful, however in an unattended install, I am unsure as to when the USF key maps to it:

FOR /F "TOKENS=3* DELIMS=	" %%? IN ('REG QUERY "HKCU\SOFTWARE\MICROSOFT\WINDOWS\CURRENTVERSION\EXPLORER\SHELL FOLDERS" /V PERSONAL^|FIND ":\"') DO (SET MYDOCS=%%?)

Where DELIMS=<tab>"

Link to comment
Share on other sites

Here is a VBS Script for My Documents
Const MY_DOCUMENTS = &H5&
Dim Act, MyDoc, MyDocPath
Set Act = CreateObject("Shell.Application")
Set MyDocPath = Act.Namespace(MY_DOCUMENTS)
Set MyDoc = MyDocPath.Self
MsgBox MyDoc.Path, 0 + 32, "My Docsuments"

Thanks GUNS'! :thumbup

Edited by Mercury_22
Link to comment
Share on other sites

I am not sure what language that is but in VBS it would be this

VBS

Const MY_DOCUMENTS = &H5&
Dim Act, MyDoc, MyDocPath
Set Act = CreateObject("Shell.Application")
Set MyDocPath = Act.Namespace(MY_DOCUMENTS)
Set MyDoc = MyDocPath.Self
Act.Run(chr(34) & MyDoc & "\FILENAME_HERE" & chr(34)),1,True

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...