Archived from groups: microsoft.public.windowsxp.general (
More info?)
Friedi wrote:
> Does anybody know the environmental variable for the files
> system directories to get the path of: C:\Documents and
> Settings\username\Start Menu\Programs.
>
> This typical path is good for Windows engl version, but the
> folders have different names in a french or polish version.
> Therefore I am looking for a shell script or environmental
> variable or a Constant to be used in different language
> versions of Windows.
>
> Can anybody give an input ?
Hi,
Read out the data in the registry value "Programs" under
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer
\Shell Folders\
As long as you haven't redirected the user profile folder away from
the system drive, this batch file that uses reg.exe (that comes
builtin with WinXP) should work for you:
--------------------8<----------------------
@echo off
setlocal
set rkey="HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
set rvalue="Programs"
set regexe=%SystemRoot%\System32\Reg.exe
:: line above for command (line might wrap)
for /f "Skip=4 Tokens=2 Delims=:" %%a in ('%regexe% QUERY %rkey% /v %rvalue%') do set rdata=%%a
:: line under for command
set ProgramsMenu=%SystemDrive%%rdata%
echo %ProgramsMenu%
pause
endlocal
--------------------8<----------------------
If you have redirected the user profile, or you need to support
Windows 2000 computers as well, use this batch file that creates a
VBScript on the fly that obtains the value:
--------------------8<----------------------
@echo off
setlocal
set tmpfile="%tmp%\pp.vbs"
echo Set oSh = CreateObject("WScript.Shell") >%tmpfile%
echo WScript.Echo oSh.RegRead("HKCU\Software\Microsoft\" _ >>%tmpfile%
echo ^& "Windows\CurrentVersion\Explorer\Shell Folders\Programs") >>%tmpfile%
for /f "tokens=*" %%a in (
'cscript.exe //Nologo %tmpfile%') do set ProgramsMenu=%%a
del %tmpfile%
echo %ProgramsMenu%
pause
endlocal
--------------------8<----------------------
--
torgeir, Microsoft MVP Scripting and WMI, Porsgrunn Norway
Administration scripting examples and an ONLINE version of
the 1328 page Scripting Guide:
http://www.microsoft.com/technet/scriptcenter/default.mspx