Mercury_22 Posted February 27, 2006 Posted February 27, 2006 (edited) Is there a env. variable name for My Documents? (in XP) Edited February 27, 2006 by Mercury_22
spazmire11 Posted February 27, 2006 Posted February 27, 2006 (edited) 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, 2006 by spazmire11
Bezalel Posted February 27, 2006 Posted February 27, 2006 No, you have to look in HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders\Personal to determine the location.
Mercury_22 Posted February 27, 2006 Author Posted February 27, 2006 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!
Delprat Posted February 27, 2006 Posted February 27, 2006 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
Yzöwl Posted February 27, 2006 Posted February 27, 2006 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>"
Mercury_22 Posted February 27, 2006 Author Posted February 27, 2006 (edited) If anyone know how to use CSIDL_MYDOCUMENTS or CSIDL_PERSONAL please let me know! (examples please) Edited February 27, 2006 by Mercury_22
gunsmokingman Posted February 27, 2006 Posted February 27, 2006 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"
Mercury_22 Posted February 27, 2006 Author Posted February 27, 2006 (edited) 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, 2006 by Mercury_22
gunsmokingman Posted February 27, 2006 Posted February 27, 2006 Your welcome I have the message box there so you could confirm the path.
Mercury_22 Posted February 27, 2006 Author Posted February 27, 2006 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" ???
gunsmokingman Posted February 27, 2006 Posted February 27, 2006 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
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now