February 27, 200620 yr Is there a env. variable name for My Documents? (in XP) Edited February 27, 200620 yr by Mercury_22
February 27, 200620 yr no there is not however you should be able to in most cases use %userprofile%\My Documents\note: to get a list of enviroment variables type set into a command prompt Edited February 27, 200620 yr by spazmire11
February 27, 200620 yr No, you have to look in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal to determine the location.
February 27, 200620 yr Author Thanks ! (I already knew that)IN VBS can i use %CSIDL_MYDOCUMENTS% or %CSIDL_PERSONAL%? How ?an example it will be very useful and much appreciated!
February 27, 200620 yr Here's how to do with a batch file :@echo offverify other 2>nulsetlocal enableextensionsif 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 textfor /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 elsewhererem 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 batchrem so they will be deleted when the batch ends, or when the endlocal command is calledrem the two next lines show you the problem : "MyDocs" is now empty...endlocalecho MyDocs=%MyDocs%:eof
February 27, 200620 yr 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>"
February 27, 200620 yr Author If anyone know how to use CSIDL_MYDOCUMENTS or CSIDL_PERSONAL please let me know! (examples please) Edited February 27, 200620 yr by Mercury_22
February 27, 200620 yr Here is a VBS Script for My DocumentsConst 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"
February 27, 200620 yr Author Here is a VBS Script for My DocumentsConst 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'! Edited February 27, 200620 yr by Mercury_22
February 27, 200620 yr Author So if i want to use this to open a file from "My Documents" folder it will be...... EX: Workbooks.Open Filename:="MyDoc.Path\Filename.xls" ???
February 27, 200620 yr I am not sure what language that is but in VBS it would be thisVBS 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
Create an account or sign in to comment