Solved

VB/ASP script to check OS then run a exe

Posted on 2008-10-28
1
1,052 Views
Last Modified: 2012-05-05
Hey guys

I have a script here for a .bat that i would like in .vbs as well. The script needs to find the OS version then run the selected .exe to that os.

This is what i have for the .bat file.

if anyone can help me create an asp script that would be huge
echo off
 

VER | FIND /I "2000"

IF %ERRORLEVEL%==0 goto W2K

IF %ERRORLEVEL%==1 goto XP
 

:W2K

echo I'm Windows 2000

echo

echo ****INSTALLING SYSTEM UPDATE PLEASE WAIT****

echo

echo off

"c:\WINNT\Patches\Windows2000-KB958644-x86-ENU.exe" /quiet /forcerestart

exit

exit
 

:XP

echo I'm Windows XP

echo

echo ****INSTALLING SYSTEM UPDATE PLEASE WAIT****

echo

echo off

"c:\WINNT\Patches\WindowsXP-KB958644-x86-ENU.exe" /quiet /forcerestart

exit

exit

Open in new window

0
Comment
Question by:tasdoj
1 Comment
 
LVL 3

Accepted Solution

by:
mitb earned 500 total points
ID: 22827497
Here is the VB script you've asked for.
strComputer = "."

Set objWMIService = GetObject("winmgmts:" _

    & "{impersonationLevel=impersonate}!\\" _

    & strComputer & "\root\cimv2")

Set colOperatingSystems = objWMIService.ExecQuery _

    ("Select * from Win32_OperatingSystem")

MessageStr="Operating System: "
 

For Each objOperatingSystem in colOperatingSystems
 

if Left(objOperatingSystem.Version,3)="5.0" then

	Wscript.Echo "I'm Windows 2000"

	Wscript.Echo ""

	Wscript.Echo "****INSTALLING SYSTEM UPDATE PLEASE WAIT****"

	Wscript.Echo ""

	Set WshShell = WScript.CreateObject("WScript.Shell")

	WshShell.Run "c:\WINNT\Patches\Windows2000-KB958644-x86-ENU.exe /quiet /forcerestart"

 elseif  Left(objOperatingSystem.Version,3)="5.1" then

	Wscript.Echo "I'm Windows XP" 

	Wscript.Echo ""

	Wscript.Echo "****INSTALLING SYSTEM UPDATE PLEASE WAIT****"

	Wscript.Echo ""

	Set WshShell = WScript.CreateObject("WScript.Shell")

	WshShell.Run "c:\WINNT\Patches\WindowsXP-KB958644-x86-ENU.exe /quiet /forcerestart"

end if
 

Next

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This is pretty cool.  The purpose of this VB Script is to help you document where JAR (Java ARchive) files and specifically java class files are located so that you can address issues seen with a client or that you can speak intelligently with a dev…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to count occurrences of each item in an array.

948 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

21 Experts available now in Live!

Get 1:1 Help Now