Solved

Batch to check server OS (ignores desktop OS kernels)

Posted on 2013-06-14
3
321 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 84

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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Learn about cloud computing and its benefits for small business owners.
This article explains how to install and use the NTBackup utility that comes with Windows Server.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…

697 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