Solved

VB/ASP script to check OS then run a exe

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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This article will show, step by step, how to integrate R code into a R Sweave document
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

734 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