Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
HI,
can any one tell me how to find the OS Host name in a .bat file ...
i have written a .bat file like this: but not working:@echo off
set answerefilepath=%1
systeminfo | find "OS Name : Microsoft Windows XP"" > nul
if %ERRORLEVEL% == 0 goto ver_xpecho Machine undetermined.
goto exit:ver_xp
echo Xp is thw OS
goto exit:exit
echo "exit"

You may want to have a look at the "ver" command, it is present on all versions of xp, while the home version doesn't have systeminfo.

i have already tried taht...but i have some problem with "ver"....my requirement is that i have to find out what is the OS and then perfom MSMQ installation.....here i have with me 3 systems where in Vista is present and in some vista machine it's ver : 6.0.6000 and in some it's 6.0.6001.So ithought i cannot use ver command.That's the reason i needa command which tells me whetehr it's XP,Vista,2008 server or 2003 server.

Ok, now I understand, anyway.
Your script basically works I just changed it a little:
@echo off set answerefilepath=%1 2>nul systeminfo | >nul find "Microsoft Windows XP"&&goto ver_xp echo Machine undetermined. goto exit :ver_xp echo Xp is thw OS goto exit :exit echo "exit"You could speed things up a little but Just getting the
info you need straight from the registry:@ECHO OFF set product= for /f "skip=4 tokens=2*" %%a in ('reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v "productname"') do ( if /i "%%b"=="mircosoft windows xp" goto ver_xp .... .... ) echo Machine undetermined. goto exit .........

hi,
the below code is not working?
it's giving an error:
"FIle not found -GOTO
File not found - ver_xp"@echo off
set answerefilepath=%1
2>nul systeminfo | >nul find "Microsoft Windows XP" goto ver_xp
echo Machine undetermined.
goto exit:ver_xp
echo XP is the OS
goto exit:exit
echo "exit"

Where's the double ampersand before "goto ver xp"?? It basically means, if the return code for the program before the double ampersand is 0 execute the command after the double ampersand.
Without the ampersands find interprets "goto" and "ver_xp" as file names, responding that they cannot be found.
2>nul systeminfo | >nul find "Microsoft Windows XP" && goto ver_xp

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |