I have a registry key of type REG_SZ. I want to identify if the registry has numeric values
for /f "tokens=1,2,3 delims== " %%x in ('regdmp HKLM\Software\MyRegistry ^| Find "v1"') do set myValue=%%y
SET "var1="&for /f "delims=0123456789" %%c in ("%myValue%") do set var1=%%c
if defined var1 echo "Not Numeric" else "Numeric"
This code works if the V1 has English characters and numbers. It doesn't work if V1 has Unicode character.
I'd suggest some small changes.
Here's a version with these adjustments.
@echo off
setlocal
for /f "tokens=1,2,3 skip=2" %%x in ('reg query HKLM\Software\MyRegistry /v v1') do set myValue=%%z
set /a var1=myValue*1
if x%var1% equ x%myValue% (
echo "Numeric"
) else (
echo "Not Numeric"
)