johnbreton Posted April 11, 2005 Posted April 11, 2005 During my Unattend setup, I have added a custom registry key to differenciate the OS language.Windows Registry Editor Version 5.00[HKEY_LOCAL_MACHINE\SOFTWARE\cie][HKEY_LOCAL_MACHINE\SOFTWARE\cie\desktop]"VersionXPStation"="1.0""OsLanguage"="FR" ou "OsLanguage"="EN"Now, I need to do a validation on the oslanguage key, so I can copy the right profile.I was think of using this:if exist "HKLM\software\cie\desktop\oslanguage" /v FR goto french But it does not workanyone has a better solution?thanksJohn
DiGGiTY Posted April 11, 2005 Posted April 11, 2005 Use the registry console tool (REG.EXE). Here's the syntax:REG QUERY KeyName [/v ValueName | /ve] KeyName [\Machine\]FullKey Machine - Name of remote machine, omitting defaults to the current machine Only HKLM and HKU are available on remote machines FullKey - in the form of ROOTKEY\SubKey name ROOTKEY [ HKLM | HKCU | HKCR | HKU | HKCC ] SubKey - The full name of a registry key under the selected ROOTKEY /v query for a specific registry key ValueName - The name, under the selected Key, to query if omitted, all values under the Key are queried /ve query for the default value or empty value name <no name> /s queries all subkeys and values
johnbreton Posted April 11, 2005 Author Posted April 11, 2005 Thanks Diggity..I am almost there.I have manage to query the key I want but I still don't know how to validate the key.reg query HKLM\software\cie\desktop" /v Oslanguage So it returns Oslanguage=FRCan I after that use something like this:reg query HKLM\software\cie\desktop" /v Oslanguageif "oslanguage"="fr" goto frenchThanks
Yzöwl Posted April 11, 2005 Posted April 11, 2005 Try something like this@ECHO OFFFOR /F "TOKENS=3 DELIMS= " %%I IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\cie\desktop" /v "OsLanguage" ^| FINDSTR "REG_SZ" ') DO SET LangOS="%%I"IF ERRORLEVEL 1 GOTO :NOTEXISTIF %LangOS%=="EN" GOTO :ENGLISHIF %LangOS%=="FR" GOTO :FRENCH:NOTEXISTECHO SORRY THE KEY DOESN'T EXISTPAUSEGOTO :EOF:ENGLISH<put your english stuff here>GOTO :EOF:FRENCH<put your french stuff here>GOTO :EOF<EDIT>Just to make sure that the copy process works okay, the space between = and " in DELIMS= " needs to be a TAB</EDIT>
DiGGiTY Posted April 11, 2005 Posted April 11, 2005 :: delims is a TAB followed by a spaceFOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\Software\cie\desktop" /v Oslanguage') DO SET Language=%%BECHO Language=%Language%Of course, you can do what you wisj with the Language variable
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