Solved

Batch to check server OS (ignores desktop OS kernels)

Posted on 2013-06-14
3
306 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
3 Comments
 
LVL 83

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

Why do Marketing keep bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

Join & Write a Comment

I have published numerous articles here at Experts Exchange that present programs/scripts written in a language called AutoHotkey. Each of those articles has a brief paragraph describing where to download the product and how to install it. I have al…
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
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 show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now