Here is a simple batch file which you can use to identify the version of Operating System (OS). I created this blog based on a question posted on the TechNet forum.
ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto Win7
ver | find "5.1" > nul
if %ERRORLEVEL% == 0 goto WinXP
echo Running Windows 7 Script
echo Running Windows XP Script
You can also use systeminfo | find "Windows XP" or systeminfo | find "Windows 7" filter instead of VER command.
The Systeminfo /S ComptuerName command can be used to collect system information from a remote machine. Here is an example to get the Logon Server information from a remote machine:
systeminfo /s RemoteComputer | find "Logon Server:"