Solved

VB/ASP script to check OS then run a exe

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

It is a general practice to get rid of old user profiles on a computer  in a LAN environment. As I have been working with a company in a LAN environment where users move from one place to some other place at times. This will make many user profil…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

717 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