Solved

VB/ASP script to check OS then run a exe

Posted on 2008-10-28
1
1,042 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
This article will show, step by step, how to integrate R code into a R Sweave document
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

763 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

11 Experts available now in Live!

Get 1:1 Help Now