Worf Posted March 12, 2006 Share Posted March 12, 2006 Hi.How do i convert the variable %%a to show up as a drive letter in the registery when i REG ADD it?for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST %%a:\Documents and Settings\%USERNAME%Set MYDOC=%%a:\Documents And Settings\%USERNAME%SET MYREG=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]REG ADD "%MYREG%" /V "Personal" /T REG_EXPAND_SZ /D "%MYDOC%\My Documents" /FNow in the registery it is showing up as %a:\Documents and Settings\UserName\My Documents How do i get it to show up as D:\Documents and Settings\UserName\My Documents?Just need to get this sorted out and i think my goal will be complete. Many ThanksWorf. Link to comment Share on other sites More sharing options...
gunsmokingman Posted March 12, 2006 Share Posted March 12, 2006 You could try it this way@Echo Off && CLS && Color 5e && Mode 75,7 && Title %Appdata%for %%a in (D E F G H I J K L M N O P Q R S T U V W X Y Z) DO IF EXIST set a=%a%\Documents And Settings goto Confirm:ConfirmSet MYDOC=%Systemdrive%\Documents And Settings\%USERNAME%\My Documentsecho %MYDOC%::SET MYREG=HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders]::REG ADD "%MYREG%" /V "Personal" /T REG_EXPAND_SZ /D "%MYDOC%" /Fset /p = Completed Script, Press Any Key To Close Link to comment Share on other sites More sharing options...
Yzöwl Posted March 12, 2006 Share Posted March 12, 2006 (edited) The only trouble is you are adding your information to the incorrect key!Here is a long winded example which should help guide you@ECHO OFF &SETLOCAL ENABLEEXTENSIONSSET "PROFLOC1=" &CALL :GETDRVSIF DEFINED PROFLOC1 GOTO :BEGINIT ELSE GOTO :ENDIT:BEGINITSET USFKEY="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders"SET SFKEY="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"ECHO/REG ADD %USFKEY% /V Favorites /T REG_EXPAND_SZ /D "%PROFLOC1%\Favorites" /FECHO/REG ADD %USFKEY% /V "My Music" /T REG_EXPAND_SZ /D "%PROFLOC1%\My Documents\My Music" /FECHO/REG ADD %USFKEY% /V "My Pictures" /T REG_EXPAND_SZ /D "%PROFLOC1%\My Documents\My Pictures" /FECHO/REG ADD %USFKEY% /V Personal /T REG_EXPAND_SZ /D "%PROFLOC1%\My Documents" /FECHO/REG ADD %SFKEY% /V Favorites /D "%PROFLOC2%\Favorites" /FECHO/REG ADD %SFKEY% /V "My Music" /D "%PROFLOC2%\My Documents\My Music" /FECHO/REG ADD %SFKEY% /V "My Pictures" /D "%PROFLOC2%\My Documents\My Pictures" /FECHO/REG ADD %SFKEY% /V Personal /D "%PROFLOC2%\My Documents" /F:ENDITENDLOCAL &GOTO :EOF:GETDRVSFOR /F %%? IN ('MOUNTVOL^|FIND ":\"^|FINDSTR/IV "A:\\ %SYSTEMDRIVE%\\" 2^>NUL') DO ( IF ERRORLEVEL 0 (IF NOT DEFINED PROFLOC1 CALL :CHECKIT %%?))GOTO :EOF:CHECKITIF EXIST "%1%USERNAME%\MY DOCUMENTS" SET "PROFLOC1=%1%%USERNAME%%" &SET "PROFLOC2=%1%USERNAME%"GOTO :EOF<Edit>I have deliberately added this as an edit so that you will see it!When you have confirmed that it works, remove ECHO/ from the beginning of the eight lines and add >NUL to the end of them.</Edit> Edited March 12, 2006 by Yzöwl Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now