RE: MS03-039 Deploy Script

From: Joe Wu [MSFT] (joewu_at_online.microsoft.com)
Date: 09/11/03


Date: Thu, 11 Sep 2003 17:50:21 GMT


Dear All,

Thanks to Diego for sharing the script with us.

To answer John's question, by default, Windows NT/95/98 systems do not ship
built-in support for WMI. To run WMI-based scripts, we can install Windows
Management Instrumentation (WMI) CORE 1.5 on these systems:
 
Windows Management Instrumentation (WMI) CORE 1.5 (Windows 95/98/NT 4.0)
http://www.microsoft.com/downloads/details.aspx?FamilyID=c174cfb1-ef67-471d-
9277-4c2b1014a31e&DisplayLang=en

Thank you for using our news group!

Regards,
Joe Wu
Product Support Services
Microsoft Corporation

Get Secure! - www.microsoft.com/security

====================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
====================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
|Content-Class: urn:content-classes:message
|From: "Diego Vasquez" <dvasquez@copaair.com>
|Sender: "Diego Vasquez" <dvasquez@copaair.com>
|References: <08c801c37872$5bc94db0$a301280a@phx.gbl>
<189401c37876$95aea2b0$a601280a@phx.gbl>
|Subject: MS03-039 Deploy Script
|Date: Thu, 11 Sep 2003 08:57:01 -0700
|Lines: 367
|Message-ID: <0bbd01c3787d$56892720$a401280a@phx.gbl>
|MIME-Version: 1.0
|Content-Type: text/plain;
| charset="iso-8859-1"
|Content-Transfer-Encoding: 7bit
|X-Newsreader: Microsoft CDO for Windows 2000
|Thread-Index: AcN4fVaJXgoT+9cNQ5iaiON1DT6REw==
|X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
|Newsgroups: microsoft.public.security
|Path: cpmsftngxa06.phx.gbl
|Xref: cpmsftngxa06.phx.gbl microsoft.public.security:34695
|NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
|X-Tomcat-NG: microsoft.public.security
|
|I'm not sure, if WMI is properly installed and the
|correct version in the destination computers it might,
|but you would have to modify the script to accomodate it
|anyway.
|
|>-----Original Message-----
|>Will this VB script patch NT4 workstation and server
|>machines, besides 2K, XP and 2K3?
|>
|>Thanks.
|>
|>John
|>>-----Original Message-----
|>>Hello guys. In technet there is a link to a script
|that
|>>helps deploying the patch using WMI:
|>>http://support.microsoft.com/default.aspx?kbid=827227
|>>I modified the file so that it detects the OS Language
|(
|>>Spanish and English for now) in addition to the OS Type
|>>and Version, im pretty sure you will be able to
|customize
|>>it for your environment:
|>>
|>>-----
|>>' Patchinstall.vbs
|>>' Patch installation script for MS03-026 and MS03-039
|>>' (c) Microsoft 2003
|>>' v1.03 cl
|>>' Modified for by dvasquez@copaair.com 11/Sep/2003
|>>' Make sure you add EN- and SP- to the appropiate patch
|>>files
|>>' option explicit
|>>
|>>on error resume next
|>>
|>>const XP_Patch = "Patch_XP.exe"
|>>const W2k_Patch = "Patch_W2k.exe"
|>>const W2k3_Patch = "Patch_W2k3.exe"
|>>
|>>If right(ucase(wscript.FullName),11)="WSCRIPT.EXE" then
|>> wscript.echo "ERROR: You must run this script
|using
|>>cscript, for example 'cscript " & wscript.scriptname
|>>& "'."
|>> wscript.quit 0
|>>end if
|>>
|>>' USAGE
|>>if wscript.arguments.count <> 2 then
|>> wscript.echo "Usage: cscript " &
|wscript.scriptname
|>>& " <IpFile.txt> <LocalPathToPatches>" & vbCrLf &
|vbCrLf
|>>& _
|>> " <LocalPathToPatches> must be a full path of a
|>>folder that contains all of these files:" & vbCrLf & _
|>> " " & XP_Patch & vbCrLf & _
|>> " " & W2k_Patch & vbCrLf & _
|>> " " & W2k3_Patch
|>> wscript.quit
|>>end if
|>>
|>>ipFile = wscript.arguments(0)
|>>localPathToPatches = wscript.arguments(1)
|>>
|>>set onet = createobject("wscript.network")
|>>set ofs = createobject("scripting.filesystemobject")
|>>
|>>' Verify that ipfile is accessible.
|>>set oipFile = ofs.opentextfile(ipFile, 1, false)
|>>if (Err.Number <> 0) then
|>> wscript.echo "Cannot open " & ipFile
|>> wscript.quit
|>>end if
|>>
|>>' Make sure to end with a \ character.
|>>if right(localPathToPatches, 1) <> "\" then
|>> localPathToPatches = localPathToPatches & "\"
|>>end if
|>>
|>>'Note that cim_datafile does not support UNC paths
|>>'so everything must be handled through mapped drives.
|>>if left(localPathToPatches, 2) = "\\" then
|>> wscript.echo "<pathToExecutable> cannot be a UNC
|>>path, please map a drive locally"
|>> wscript.quit
|>>end if
|>>
|>>
|>>
|>>
|>>exeWinXP = ofs.getfile(localPathToPatches + "EN-
|>>"+XP_Patch).name
|>>exeW2k = ofs.getfile(localPathToPatches + "EN-
|>>"+W2k_Patch).name
|>>exeW2k3 = ofs.getfile(localPathToPatches + "EN-
|>>"+W2k3_Patch).name
|>>
|>>exeWinXP_sp = ofs.getfile(localPathToPatches + "SP-
|>>"+XP_Patch).name
|>>exeW2k_sp = ofs.getfile(localPathToPatches + "SP-
|>>"+W2k_Patch).name
|>>exeW2k3_sp = ofs.getfile(localPathToPatches + "SP-
|>>"+W2k3_Patch).name
|>>
|>>' Verify that the patches are accessible.
|>>if ((len(exeWinXP) = 0) OR (len(exeW2k) = 0) OR (len
|>>(exeW2k3) = 0)) then
|>> wscript.echo "Cannot find patch files."
|>> wscript.echo "Please verify that the
|>><LocalPathToPatches> folder contains all of these
|files:"
|>>& vbCrLf & _
|>> " " & XP_Patch & vbCrLf & _
|>> " " & W2k_Patch & vbCrLf & _
|>> " " & W2k3_Patch
|>> wscript.quit
|>>end if
|>>
|>>
|>>set osvcLocal = getobject("winmgmts:root\cimv2")
|>>
|>>'The error-handling code is below the function that may
|>>throw one - execute it.
|>>on error resume next
|>>
|>>while not oipFile.atEndOfStream
|>> ip = oipFile.ReadLine()
|>> wscript.echo vbCrLf & "Connecting to " & ip & "..."
|>>
|>> Err.Clear
|>> set osvcRemote = GetObject("winmgmts:\\" & ip
|>>& "\root\cimv2")
|>>
|>> if (Err.Number <> 0) then
|>> wscript.echo "Failed to connect to " & ip
|& "."
|>> else
|>>
|>> exeCorrectPatch = detectOSPatch(osvcRemote)
|>> wscript.echo "Filename: " & execorrectpatch
|>> if (exeCorrectPatch <> "") then
|>> ' Lay the bits on the remote computer.
|>> wscript.echo "Installing patch " &
|>>exeCorrectPatch & "..."
|>>
|>> onet.mapnetworkdrive "z:", "\\" & ip
|>>& "\C$"
|>> set osourceFile = osvcLocal.get
|>>("cim_datafile=""" & replace
|>>(localPathToPatches, "\", "\\") & exeCorrectPatch
|& """")
|>> ret = osourceFile.Copy
|("z:\\Patchinst.exe")
|>>
|>> if (ret <> 0 and ret <> 10) then
|>> ' Failure detected and failure was
|>>not "file already exists."
|>> wscript.echo "Failed copy to " & ip
|>>& " - error: " & ret
|>> else
|>> set oprocess = osvcRemote.Get
|>>("win32_process")
|>>
|>> ' Start the installation without
|user
|>>interaction, and force a restart after completion.
|>> ret = oprocess.create
|>>("c:\\Patchinst.exe -q -f")
|>> if (ret <> 0) then
|>> wscript.echo "Failed to start
|>>process on " & ip & ": " & ret
|>> else
|>> ' Get a reference to the file
|>>that was copied.
|>> set odestFile = osvcLocal.get
|>>("cim_datafile=""z:\\Patchinst.exe""")
|>>
|>> ' Wait for the installation to
|>>complete.
|>> for waitTime = 0 to 120 '
|>>Lay and wait--up to two minutes for the installation to
|>>complete.
|>> wscript.Sleep 1000 '
|>>Sleep one second.
|>> ' Delete temporary file
|as
|>>soon as possible after it is freed.
|>> if (odestFile.Delete() =
|0)
|>>then
|>> exit for
|>> end if
|>> next ' Otherwise, loop again
|and
|>>keep waiting...
|>>
|>> wscript.echo "Installation
|>>successful."
|>>
|>> end if 'Create process
|succeeded.
|>> end if 'Copy succeeded.
|>>
|>> onet.removenetworkdrive "z:", true
|>> end if ' The script knows which patch to
|>>install.
|>> end if ' Do the next IP address, then the next IP
|>>address...
|>>wend
|>>
|>>oipFile.close()
|>>
|>>'Clean up, remove drive mapping (check this time,
|because
|>>it may not have been mapped).
|>>if ofs.folderexists("z:\") then
|>> onet.removenetworkdrive "z:", true
|>>end if
|>>
|>>wscript.echo vbCrLf & "Patching complete. Exiting."
|>>
|>>function detectOSPatch(osvcRemote)
|>>
|>> set oOSInfo = osvcRemote.InstancesOf
|>>("Win32_OperatingSystem")
|>> 'Only one instance is ever returned (the currently
|>>active OS), even though the following is a foreach.
|>> for each objOperatingSystem in oOSInfo
|>>
|>>
|>>
|>> if (objOperatingSystem.OSType <> 18) then
|>> ' Make sure that this computer is
|Windows
|>>NT-based.
|>> wscript.echo ip & " is not a Windows XP,
|>>Windows 2000, or Windows 2003 Server computer."
|>> else
|>> select case objOperatingSystem.OSLanguage
|>>case "9" OSLang = "EN"
|>>case "3081" OSLang = "EN"
|>>case "10249" OSLang = "EN"
|>>case "4105" OSLang = "EN"
|>>case "6153" OSLang = "EN"
|>>case "8201" OSLang = "EN"
|>>case "5129" OSLang = "EN"
|>>case "7177" OSLang = "EN"
|>>case "11273" OSLang = "EN"
|>>case "2057" OSLang = "EN"
|>>case "1033" OSLang = "EN"
|>>case "11274" OSLang = "SP"
|>>case "16394" OSLang = "SP"
|>>case "13322" OSLang = "SP"
|>>case "9226" OSLang = "SP"
|>>case "5130" OSLang = "SP"
|>>case "7178" OSLang = "SP"
|>>case "12298" OSLang = "SP"
|>>case "17418" OSLang = "SP"
|>>case "4106" OSLang = "SP"
|>>case "18442" OSLang = "SP"
|>>case "3082" OSLang = "SP"
|>>case "2058" OSLang = "SP"
|>>case "19466" OSLang = "SP"
|>>case "6154" OSLang = "SP"
|>>case "15370" OSLang = "SP"
|>>case "10250" OSLang = "SP"
|>>case "20490" OSLang = "SP"
|>>case "1034" OSLang = "SP"
|>>case "14346" OSLang = "SP"
|>>case "8202" OSLang = "SP"
|>>
|>> End Select
|>> wscript.echo ip &" - " &
|>>objOperatingSystem.OSLanguage & ":" &oslang & " - " &
|>>objOperatingSystem.Caption & " SP" &
|>>objOperatingSystem.ServicePackMajorVersion & "("&
|>>objOperatingSystem.Version & ")"
|>>
|>> if oslang = "EN" then
|>>
|>> if (objOperatingSystem.Version
|>>= "5.0.2195") then
|>> ' Windows 2000 SP2, SP3, SP4.
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 2) or
|>>(objOperatingSystem.ServicePackMajorVersion = 3) or
|>>(objOperatingSystem.ServicePackMajorVersion = 4) then
|>> systemType = exeW2k
|>> end if
|>>
|>> elseif (objOperatingSystem.Version
|>>= "5.1.2600") then
|>> ' Windows XP RTM, SP1.
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 0) or
|>>(objOperatingSystem.ServicePackMajorVersion = 1) then
|>> systemType = exeWinXP
|>> end if
|>>
|>> elseif (objOperatingSystem.Version
|>>= "5.2.3790") then
|>> ' Windows Server 2003 RTM
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 0) then
|>> systemType = exeW2k3
|>> end if
|>> end if
|>>
|>> elseif oslang = "SP" then
|>>
|>> if (objOperatingSystem.Version
|>>= "5.0.2195") then
|>> ' Windows 2000 SP2, SP3, SP4.
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 2) or
|>>(objOperatingSystem.ServicePackMajorVersion = 3) or
|>>(objOperatingSystem.ServicePackMajorVersion = 4) then
|>> systemType = exeW2k_sp
|>> end if
|>>
|>> elseif (objOperatingSystem.Version
|>>= "5.1.2600") then
|>> ' Windows XP RTM, SP1.
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 0) or
|>>(objOperatingSystem.ServicePackMajorVersion = 1) then
|>> systemType = exeWinXP_sp
|>> end if
|>>
|>> elseif (objOperatingSystem.Version
|>>= "5.2.3790") then
|>> ' Windows Server 2003 RTM
|>> if
|>>(objOperatingSystem.ServicePackMajorVersion = 0) then
|>> systemType = exeW2k3_sp
|>> end if
|>> end if
|>>
|>>
|>>
|>> end if
|>>
|>> if (systemType = "") then
|>> 'This was a Windows NT-based
|>>computer, but not with a valid service pack.
|>> wscript.echo "Could not patch " &
|ip
|>>& " - unhandled OS version: " &
|>>objOperatingSystem.Caption & " SP" &
|>>objOperatingSystem.ServicePackMajorVersion & "("&
|>>objOperatingSystem.Version & ")"
|>> end if
|>> end if
|>>
|>> next
|>> wscript.echo systemtype
|>> detectOSPatch = systemType
|>>
|>>end function
|>>
|>>-----
|>>.
|>>
|>.
|>
|



Relevant Pages

  • Re: Offline Batch Update
    ... open a notepad window and type the file name of the patch ... >Visual Basic Script Hotfix Installation System: ... >Command-Line Switches For Windows Software Update ... >Command-Line Switches for Microsoft Software Update ...
    (microsoft.public.windowsxp.setup_deployment)
  • Re: Microsoft Warns of New Windows Flaw (March 19, 2003 )
    ... In WINDOWS SETUP in ADD/REMOVE PROGRAMS of Control Panel ... Uninstall Outlook Express, ... Java, Javascript, ActiveX and all the other script runner toys Billy ... Install WebWasher the spammers are terrified of free from ...
    (comp.security.misc)
  • Re: Microsoft Warns of New Windows Flaw (March 19, 2003 )
    ... In WINDOWS SETUP in ADD/REMOVE PROGRAMS of Control Panel ... Uninstall Outlook Express, ... Java, Javascript, ActiveX and all the other script runner toys Billy ... Install WebWasher the spammers are terrified of free from ...
    (comp.security.firewalls)
  • Re: Really slow to get information from Win32_UserAccount
    ... This should get the fullname of current user (local as well as ... WMI provider for the Win32_UserAccount class could avoid having to ... The only way to find out really, is to try my script and see what ... If you mean all the machines that would run the code then no, some of them could be Windows NT 4.0 or Windows 9x.. ...
    (microsoft.public.win32.programmer.wmi)
  • [NT] Flaw in Windows Script Engine Could Allow Code Execution
    ... The following security advisory is sent to the securiteam mailing list, and can be found at the SecuriTeam web site: http://www.securiteam.com ... The Windows Script Engine provides Windows operating systems with the ... blocked by Outlook Express 6.0 and Outlook 2002 in their default ...
    (Securiteam)