/build/static/layout/Breadcrumb_cap_w.png

BAT file to search for a VALUE in registry

Hi All,

I've written a batch file to search the registry key HKLM\Software\Oracle and all its subkeys for the string value 'NLS_LANG'.If present change its value to abc. My script works for Windows 7, Windows Vista, but says too many commandline for Windows XP.

Can someone pls help.

Set var1=abc
Set var2=DD-MON-YYYY
for /f "tokens=*" %%a in ('reg query HKLM\SOFTWARE\ORACLE /v "NLS_LANG" /s ^| find /i "\ORACLE"') do (
echo %%a
REG ADD "%%a" /v NLS_LANG /t REG_SZ /f /d %var1%
)

Thanks

0 Comments   [ + ] Show comments

Answers (5)

Posted by: anonymous_9363 14 years ago
Red Belt
0
DOS command files are too painful...If it were me, I'd use a proper scripting language, e.g. VBScript or PowerShell. And before you ask, there are quadzillions of sample scripts out there to query/delete from/add to the registry.
Posted by: mdallen 14 years ago
Senior Yellow Belt
0
The problem you are running into is that for the REG command in XP, /s and /v are mutually exclusive. You cannot issue both on the same command. I believe that /s will suffice for your instance, you will just be parsing more returned lines using the find command.
Posted by: nprat 14 years ago
Yellow Belt
0
Thanks for your reply.
I tried VBScript too. My VBscript checks for the value 'NLS_LANG' in HKLM\SOFTWARE\ORACLE and all its Subkeys but not their subkeys.
Can any one please help me with the VBScript or Bat file to check for the value NLS_LANG in HKLM\SOFTWARE\ORACLE and all its subkeys and their subkeys and change its value to ABC.
Posted by: nprat 14 years ago
Yellow Belt
0
VBScab Thanks for your reply. Can you please help me with the script as I am new to VBScripting.

I tried VBScript too. My VBscript checks for the value 'NLS_LANG' in HKLM\SOFTWARE\ORACLE and all its Subkeys but not their subkeys and beyond.

Pls help
Posted by: anonymous_9363 14 years ago
Red Belt
0
Go to jsware.net and find the class pack. In there, you'll find a registry class, which you can include/attach to any of your scripts to give a (relatively) neat way to access the registry and most of its data types (the Shell registry methods don't include some of the common data types...).

Don't be put off by the word "class": it's easy to use and contains example code. The reason I mention it is that it includes a function to enumerate all sub-keys and another to enumerate the values and data in a key. The entries get put into an array, which you can then loop through, searching for your string.
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ