Is there a way to determine what version a user's Windows version they are running a batch file without have to discover (I am assuming) through RegEdit?
I want to create a validation that a batch file can only be run in Vista or Windows 7.
Thanks
Jeff in Seattle
Determine Windows Version a batch file is running within?
Moderator: DosItHelp
-
- Posts: 7
- Joined: 06 Nov 2008 19:55
Re: Determine Windows Version a batch file is running within?
This should work:
Regards
aGerman
Code: Select all
@echo off &setlocal
REM if older than XP then reg.exe is unknown
if exist "%SystemRoot%\system32\reg.exe" (
REM read the "ProductName" key
for /f "tokens=3 delims= " %%a in ('reg query "HKLM\Software\Microsoft\Windows NT\CurrentVersion" /v "ProductName" 2^>nul') do set "ProductName=%%a"
)
REM look for "vista" or "windows 7" (not case sensitive by using /i)
REM if found then jump to :OK label
echo.%ProductName%|findstr /i /c:"vista">nul && goto OK
echo.%ProductName%|findstr /i /c:"windows 7">nul && goto OK
REM otherwise (or if ProductName is not defined)
echo Your OS is too old.
pause
goto :eof
:OK
echo Right OS.
pause
Regards
aGerman
-
- Posts: 7
- Joined: 06 Nov 2008 19:55
Re: Determine Windows Version a batch file is running within?
Thanks,
I will give this a try.
Jeff
a Seattleite
I will give this a try.
Jeff
a Seattleite