Code broken? My stupid logic error
Posted: 09 Aug 2013 01:27
Hello everyone...
I have this logic error and I can't figure out how to fix it, due to resent posts on the forum the code was quite helpful if my code did't work I could use the other code...
Well my problem to check is reg.exe exists and if it does it must use option one, else use option 2, but the 1st option does not work inside a exist statement.
Thanks for your time
.
I have this logic error and I can't figure out how to fix it, due to resent posts on the forum the code was quite helpful if my code did't work I could use the other code...
Code: Select all
if exist "reg.exe" (
for /f "tokens=3" %%k in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentVersion') do set "OSVersion=%%k" >nul 2>nul
for /f "tokens=3" %%i in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v CurrentBuild') do set "OSbuild=%%i" >nul 2>nul
set OSversionRe=%OSversion%
) else (
for /F "tokens=2 delims=[]" %%a in ('ver.exe') do (
for /F "tokens=2-4 delims=. " %%b in ("%%a") do (
set "OSversion=%%b" & set "OSsubversion=%%c" & set "OSbuild=%%d"
set /a "OSversionRe=%OSversion%.%OSsubversion%"
)
) )
Well my problem to check is reg.exe exists and if it does it must use option one, else use option 2, but the 1st option does not work inside a exist statement.
Thanks for your time
