/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


Query Registry for the REG-SZ Data

02/09/2016 1834 views
We added a new license server and I need to ensure everyone is pointing to it so I would like to return the Data of a REG_SZ Named "Server Order" in the registry.

The Name Server Order, Type is REG_SZ and Data will be the server name i.e.: LicSVR1

I tried the following and can't seem to get the syntax right

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\wer\Licensing\"Server Order"="LicSVR1""

It doesn't find it, I tried a few different switches, the /t is supposed to find the REG_SZ data but I can't get it to work

Thanks in advance for the help





Answer Summary:
2 Comments   [ + ] Show comments

Comments

  • So I got this to work on the command line, it returned the Server Order with the Server Name I was looking for:

    reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\wer\Licensing\" /v "Server Order"

    And it returned
    Server Order REG_SZ LicSVR1

    But now I have to get the correct syntax in the script to search and if it finds the LicSVR1 the script continues if not it installs the correct one. I have all the script working except for when it look to see what the server is??

    Thanks again.
    • can you post your script
      • Here is the part I am talking about:

        reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\wer\Licensing\" /v "Server Order" (This is where I have tried = "LicSVR1" and others to say if you see LicSVR1 add to flag file if not install is from ....)
        if %errorlevel% EQU 0 (
        echo %date% %computername% LicSVR1 Installed >> "C:\Windows\System32\flags\wer.txt"
        )
        if %errorlevel% NEQ 0 (
        "\\networkshare\install.cmd"
        echo %date% %computername% LicSVR1 Re-Installed >> "C:\Windows\System32\flags\wer.txt"
        goto :eof
        )
  • OMG is it that I missed to close the quote ) after the EQU 0 ( ???
    • you do have two open and only one close quote
      • Sorry fixed it but how can I get the query to look for Server Order data value, i.e.: Server Order = LicSVR1 and then determine if it's EQU or NEQ?

Answer Chosen by the Author

0
This worked:

reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\wer\Licensing\" |find "LicSVR1.domain"
if %errorlevel% EQU 0 (
echo %date% %computername% LicSVR1 Installed >> "C:\Windows\System32\flags\wer.txt"
)
Answered 02/09/2016 by: Newbie0000
Orange Senior Belt


Community Chosen Answer

2
reg query "HKLM\SOFTWARE\Wow6432Node\wer\Licensing /v "Server Order"
Answered 02/09/2016 by: SMal.tmcc
Red Belt

All Answers

1
you need to do something like this in a batch to run this or that based on the key

reg query "HKLM\SOFTWARE\Wow6432Node\wer\Licensing /v "Server Order" /f LicSVR1 /d
if %ERRORLEVEL% EQU 0 goto :equal

Rem change this to the not equal stuff you want to do
:not equal
echo not equal
pause
end

Rem change this to the equal stuff you want to do
:equal
echo equal
pause
end

Answered 02/09/2016 by: SMal.tmcc
Red Belt

 
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