?
Solved

VB/ASP script to check OS then run a exe

Posted on 2008-10-28
1
Medium Priority
?
1,082 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 2000 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

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/…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

762 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