Solved

VB/ASP script to check OS then run a exe

Posted on 2008-10-28
1
1,067 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

839 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