I'm trying to create a simple batch file that uses the reg query command to check for the existence of a value in a registry key, specifically
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
ProxyEnable
key.
If I run this command:
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /v ProxyEnable /f 0x1 /d
It returns the following:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
ProxyEnable REG_DWORD 0x0
It's as if it's not accepting my /f
search field, as I would expect the command as entered to return no results since my value for that key is 0x0
.
I've tried using quotes around the "0x1
", and other combinations, but wondering if I'm doing something wrong.
Thanks in advance!
Reg Query /?
,/f Specifies the data or pattern to search for. Use double quotes if a string contains spaces. Default is "*".
That said, as you're only reading the key, can you not just set the data to a variable and check it with anIf %variable Gtr 0
comparison - Comporeg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings" /f 1 /t REG_DWORD |find /I "ProxyEnable"
- SquashmanFOR /F
to capture the output of theREG QUERY
. - Squashman