how to find out user's windows in batch?
if xp echo "you have windows xp"
else echo "you have another windows"
find out user's windows
Moderator: DosItHelp
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: find out user's windows
This may not be the best way, but it works.
Code: Select all
for /f "tokens=2 delims=[]" %%a in ('ver') do set winver=%%a
if "%winver%"=="Version 5.1.2600" (
echo.This is Windows XP
) else (
echo.This is another version of windows.
)
-
- Posts: 84
- Joined: 08 Sep 2010 10:25
- Location: Iran,Kashan
- Contact:
Re: find out user's windows
Is it possible to use %ERORLEVEL% in this commands?
like this:
ver|find "windows xp"
if %ERORLEVEL% equ 1 echo ...
like this:
ver|find "windows xp"
if %ERORLEVEL% equ 1 echo ...
-
- Posts: 79
- Joined: 13 Dec 2010 10:32
Re: find out user's windows
Good point. Not sure why i didn't look this way sooner...
Code: Select all
ver|findstr /c:"5.1.2600" && echo.windows xp || echo.not XP
Re: find out user's windows
Another way is to read the registry keys.
Mostly %version% would be good enough for determining.
http://msdn.microsoft.com/en-us/library/ms724832%28v=vs.85%29.aspx
Regards
aGerman
Code: Select all
@echo off &setlocal
for /f "tokens=1,2*" %%a in ('reg Query "HKLM\Software\Microsoft\Windows NT\CurrentVersion"') do (
if /i "%%a"=="CurrentBuildNumber" set "build=%%c"
if /i "%%a"=="CurrentVersion" set "version=%%c"
if /i "%%a"=="ProductName" set "name=%%c"
)
echo %build%
echo %version%
echo %name%
pause
Mostly %version% would be good enough for determining.
http://msdn.microsoft.com/en-us/library/ms724832%28v=vs.85%29.aspx
Regards
aGerman