Solved

Batch to check server OS (ignores desktop OS kernels)

Posted on 2013-06-14
3
334 Views
Last Modified: 2013-06-28
I am trying to make a batch that checks the version of the OS and if found, moves on to a part of the script.  I have two problems.  This script below works for windows xp, vista, 7...etc but not windows server OS.  
Example of what I want...
ver | find "2003" > nul
:: error 0 means found
if %ERRORLEVEL% == 0 goto Nextgen
) ELSE ( 
ver | find "2008" > nul
:: error 0 means found
if %ERRORLEVEL% == 0 goto Nextgen
) ELSE ( 
ver | find "2012" > nul
:: error 0 means found
if %ERRORLEVEL% == 0 goto Nextgen

Open in new window


if I use something more specific like the below to find server 2008, the problem is that this is also the kernel for windows 7 and I cannot have that.
VER | FINDSTR /IL "6.1." > NUL

Open in new window


Can sombody help me create a OS check that ONLY looks for windows servers 2003, 2008, and 2012?  And ignores desktop OS kernels like windows 7?

Thanks in advance
0
Comment
Question by:icecom4
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 85

Accepted Solution

by:
oBdA earned 450 total points
ID: 39248602
You can simply use a "net accounts" to find the computer role; every desktop OS since at least NT4 will show up as WORKSTATION.
The PDC (emulator) would be PRIMARY, a BDC BACKUP, and a regular server should be SERVER.
So try
@echo off
setlocal
net accounts | find /i "WORKSTATION"
if not errorlevel 1 (
	echo Workstation OS detected, leaving script ...
	goto :eof
)
REM We're on a server OS

Open in new window

0
 
LVL 13

Assisted Solution

by:rhinoceros
rhinoceros earned 50 total points
ID: 39270736
Batch File to Correctly Determine Operating System Version
http://malektips.com/xp_dos_0025.html
0
 

Author Closing Comment

by:icecom4
ID: 39285081
Thanks guys, I used oBdA's script in my production batch, but that other script seems like something I will need in the future.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

New Windows 7 Installations take days for Windows-Updates to show up and install. This can easily be fixed. I have finally decided to write an article because this seems to get asked several times a day lately. This Article and the Links apply to…
The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question