Jump to content

Registry question


Recommended Posts

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 work

anyone has a better solution?

thanks

John

Link to comment
Share on other sites


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

Link to comment
Share on other sites

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=FR

Can I after that use something like this:

reg query HKLM\software\cie\desktop" /v Oslanguage

if "oslanguage"="fr" goto french

Thanks

Link to comment
Share on other sites

Try something like this

@ECHO OFF
FOR /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 :NOTEXIST
IF %LangOS%=="EN" GOTO :ENGLISH
IF %LangOS%=="FR" GOTO :FRENCH

:NOTEXIST
ECHO SORRY THE KEY DOESN'T EXIST
PAUSE
GOTO :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>

Link to comment
Share on other sites

:: delims is a TAB followed by a space

FOR /F "tokens=2* delims= " %%A IN ('REG QUERY "HKLM\Software\cie\desktop" /v Oslanguage') DO SET Language=%%B

ECHO Language=%Language%

Of course, you can do what you wisj with the Language variable

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...