?
Solved

Batch to check server OS (ignores desktop OS kernels)

Posted on 2013-06-14
3
Medium Priority
?
341 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 1800 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 200 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Suggested Courses
Course of the Month9 days, 21 hours left to enroll

762 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