/build/static/layout/Breadcrumb_cap_w.png

Query Registry for the REG-SZ Data

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






2 Comments   [ + ] Show 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. - Newbie0000 5 years ago
    • can you post your script - SMal.tmcc 5 years ago
      • 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
        ) - Newbie0000 5 years ago
  • OMG is it that I missed to close the quote ) after the EQU 0 ( ??? - Newbie0000 5 years ago
    • you do have two open and only one close quote - SMal.tmcc 5 years ago
      • 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? - Newbie0000 5 years ago

Answers (3)

Answer Summary:
Posted by: SMal.tmcc 5 years ago
Red Belt
2
reg query "HKLM\SOFTWARE\Wow6432Node\wer\Licensing /v "Server Order"
Posted by: SMal.tmcc 5 years ago
Red Belt
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

Posted by: Newbie0000 5 years ago
Orange Senior Belt
0

Top Answer

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"
)
 
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