Solved

VB/ASP script to check OS then run a exe

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Batch, VBS, and scripts in general are incredibly useful for repetitive tasks.  Some tasks can take a while to complete and it can be annoying to check back only to discover that your script finished 5 minutes ago.  Some scripts may complete nearly …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
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…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

713 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