Имя пользователя:
Пароль:
 

Показать сообщение отдельно

Пользователь


Сообщения: 87
Благодарности: 4

Профиль | Сайт | Отправить PM | Цитировать


Iska, Ваш код отлично работает!!! Правда имел возможность потестить пока только на Windows XP x86 ENG. Позже постараюсь потестить на других ОС в более сложных условиях.

Я немного его адаптировал под себя и у меня он сейчас выглядит
так

Код: Выделить весь код
Option Explicit

Dim strHotFixID
Dim strServicePackInEffect

Dim strPath2HotFix
Dim strPath2Log


Dim objDictionary
Dim objFSO

Dim strComputer

Dim objSWbemLocator
Dim objSWbemServicesEx
Dim collSWbemObjectSet
Dim objSWbemObjectEx

Dim strPrivilege
Dim strOSVersion
Dim strHotFixFullPath


strHotFixID            = "File 1"
strServicePackInEffect = "KB943729"

strPath2HotFix         = "\\TestDC.Company.Local\Distributives\KB943729"
strPath2Log            = "\\TestDC.Company.Local\Distributives\KB943729\Logs"

Set objDictionary = WScript.CreateObject("Scripting.Dictionary")

With objDictionary
	.Add "Windows XP x86 ENU",             "WindowsXP-KB943729-x86-ENU.exe"
	.Add "Windows XP x86 RUS",             "WindowsXP-KB943729-x86-RUS.exe"
	
	.Add "Windows XP x64 ENU",             "WindowsXP-KB943729-x64-ENU-RUS.exe"
	.Add "Windows XP x64 RUS",             "WindowsXP-KB943729-x64-ENU-RUS.exe"

	
	.Add "Windows Server 2003 x86 ENU",    "WindowsServer2003-KB943729-x86-ENU.exe"
	.Add "Windows Server 2003 x86 RUS",    "WindowsServer2003-KB943729-x86-RUS.exe"

	.Add "Windows Server 2003 x64 ENU",    "WindowsServer2003-KB943729-x64-ENU.exe"
	.Add "Windows Server 2003 x64 RUS",    "WindowsServer2003-KB943729-x64-RUS.exe"
	
	
	.Add "Windows Vista x86 ENU",          "WindowsVista6.0-KB943729-x86-ENU.msu"
	.Add "Windows Vista x86 RUS",          "WindowsVista6.0-KB943729-x86-RUS.msu"

	.Add "Windows Vista x64 ENU",          "WindowsVista6.0-KB943729-x64-ENU.msu"
	.Add "Windows Vista x64 RUS",          "WindowsVista6.0-KB943729-x64-RUS.msu"
End With

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")


strComputer = "."

Set objSWbemLocator    = WScript.CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServicesEx = objSWbemLocator.ConnectServer(strComputer, "root\cimv2")

For Each strPrivilege In Array("SeBackupPrivilege", "SeRestorePrivilege", "SeShutdownPrivilege", "SeSecurityPrivilege", "SeTakeOwnershipPrivilege")
	objSWbemServicesEx.Security_.Privileges.AddAsString strPrivilege, True
Next

Set collSWbemObjectSet = objSWbemServicesEx.ExecQuery( _
	"SELECT * FROM Win32_QuickFixEngineering WHERE HotFixID='" & strHotFixID & "' AND ServicePackInEffect = '" & strServicePackInEffect & "'")

If collSWbemObjectSet.Count = 0 Then
	strOSVersion = GetStandardWindowsVersion(objSWbemServicesEx)
	
	If objDictionary.Exists(strOSVersion) Then
		strHotFixFullPath = objFSO.BuildPath(strPath2HotFix, objDictionary.Item(strOSVersion))
		
		WScript.Echo """" & strHotFixFullPath & """" & _
			" /quiet /norestart /log:""" & strPath2Log & "\" & _
			strHotFixID & "_" & strServicePackInEffect & " [" & _
			WScript.CreateObject("WScript.Network").ComputerName & "].log"""
		
		If objFSO.FileExists(strHotFixFullPath) Then
			With objSWbemServicesEx.Get("Win32_Process")
				If .Create("""" & strHotFixFullPath & """" & _
					" /quiet /norestart /log:""" & strPath2Log & "\" & _
					strHotFixID & "_" & strServicePackInEffect & " [" & _
					WScript.CreateObject("WScript.Network").ComputerName & "].log""") = 0 Then
					
					' Success execute
				Else
					'Can't execute
				End If
			End With
		Else
			' File not found
		End If
	Else
		' OS <--> HotFix link not found
	End If
End If

Set collSWbemObjectSet = Nothing
Set objSWbemServicesEx = Nothing
Set objSWbemLocator    = Nothing

objDictionary.RemoveAll
Set objDictionary      = Nothing

WScript.Quit 0
'=============================================================================

'=============================================================================
Function GetStandardWindowsVersion(objSWbemServicesEx)
	Dim objDictionary
	
	Dim objSWbemObjectEx_Win32_OperatingSystem
	Dim objSWbemObjectEx_Win32_ComputerSystem
	
	Dim strOS
	
	
	Set objDictionary = WScript.CreateObject("Scripting.Dictionary")
	
	With objDictionary
		.Add "32-bit",       "x86"
		.Add "64-bit",       "x64"
		
		.Add "X86-based PC", "x86"
		.Add "X64-based PC", "x64"
	End With
	
	
	For Each objSWbemObjectEx_Win32_OperatingSystem In objSWbemServicesEx.InstancesOf("Win32_OperatingSystem")
		With objSWbemObjectEx_Win32_OperatingSystem
			Select Case .Version
				'==========================================================================
				Case "5.1.2600"
					strOS = "Windows XP x86"
				'==========================================================================
				Case "5.2.3790"
					Select Case .ProductType
						Case 1
							strOS = "Windows XP x64"
						Case 2, 3
							For Each objSWbemObjectEx_Win32_ComputerSystem In .InstancesOf("Win32_ComputerSystem")
								strOS = "Windows Server 2003 " & objDictionary.Item(objSWbemObjectEx_Win32_OperatingSystem.SystemType)
								
								Exit For
							Next
					End Select
				'==========================================================================
				Case "6.0.6000", "6.0.6001", "6.0.6002"
					Select Case .ProductType
						Case 1
							strOS = "Windows Vista "          & objDictionary.Item(.OSArchitecture)
						Case 2, 3
							strOS = "Windows Server 2008 "    & objDictionary.Item(.OSArchitecture)
					End Select
				'==========================================================================
				Case "6.1.7600", "6.1.7601"
					Select Case objSWbemObjectEx.ProductType
						Case 1
							strOS = "Windows 7 "              & objDictionary.Item(.OSArchitecture)
						Case 2, 3
							strOS = "Windows Server 2008 R2 " & objDictionary.Item(.OSArchitecture)
					End Select
				'==========================================================================
				Case Else
					' Other
			End Select
			
			Select Case .OSLanguage
				Case 1033
					strOS = strOS & " ENU"
				Case 1049
					strOS = strOS & " RUS"
				Case Else
					' Other
			End Select
			
			Exit For
		End With
	Next
	
	objDictionary.RemoveAll
	Set objDictionary = Nothing
	
	WScript.Echo strOS
	
	GetStandardWindowsVersion = strOS
End Function
'=============================================================================


Эта, конкретная KB'шка не нужна для Windows 7, Windows Server 2008, Windows Server 2008 R2, поэтому из objDictionary я убрал упоминания о них для этого конкретного случая.
А вообще, судя по
Код: Выделить весь код
strHotFixID = "File 1"
strServicePackInEffect = "KB943729"
у меня сложилось ощущение, что внутрь этого скрипта можно засунуть и другие KB'шки, т.е. Вы делали некий универсальный инструментарий для развёртывания KB - верно? Также косвенно об этом говорит имя файла логов, получившегося у меня: File 1_KB943729 [TESTCLIENT].log Было бы неплохо в таком случае, если бы Вы приложили бы к нему небольшое описание - инструкцию по эксплуатации - как его масштабировать для нескольких KB, как быть в случае, если KB'шки есть только для некоторых ОС (как в случае с KB943729).
Я не смог понять и разобраться для чего мне в коде для конкретной KB'шки, которой нет под Win 7, Win 2008, 2008R, вот эти строки.
Код: Выделить весь код
						Case 2, 3
							strOS = "Windows Server 2008 "    & objDictionary.Item(.OSArchitecture)
					End Select
				'==========================================================================
				Case "6.1.7600", "6.1.7601"
					Select Case objSWbemObjectEx.ProductType
						Case 1
							strOS = "Windows 7 "              & objDictionary.Item(.OSArchitecture)
						Case 2, 3
							strOS = "Windows Server 2008 R2 " & objDictionary.Item(.OSArchitecture)
удалять их не стал, ибо "не понятно".

Верно ли я понимаю, что скрипт предполагает только одно место хранения для KB'шек?

Код: Выделить весь код
strPath2HotFix         = "\\TestDC.Company.Local\Distributives\KB943729"
Если это так, то это не очень универсально, ибо предполагает, что KB должны ВСЕ храниться в одном месте. Это не очень удобно. Нельзя ли для каждой KB указывать свой путь?

Если я вообще не правильно понял Ваш скрипт и несу ерунду, объясните, пожалуйста, как правильно в теории должно быть.

UPD:
Кстати, вот содержимое лога. Может из него удастся как-то что-то улучшить
Лог

Код: Выделить весь код
[File 1_KB943729 [TESTCLIENT].log]
0.250: ================================================================================
0.250: 2012/07/02 21:29:05.140 (local)
0.250: c:\52fa1b1dbf5491ca582ac4\update\update.exe (version 6.3.4.1)
0.250: Hotfix started with following command line: /quiet /norestart /log:\\TestDC.Company.Local\Distributives\KB943729\Logs\File 1_KB943729 [TESTCLIENT].log 
0.250: In Function GetBuildType, line 1170, RegQueryValueEx failed with error 0x2
0.266:  C:\WINDOWS\system32\xmllite.dll is Present
0.266: Condition succeeded for section Test.PresentOp.Section in Line 1 of PreRequisite 
0.266: DoInstallation: HpInitializeLibrary failed; status=0xe0000106, location=2749
0.266: Hotpatching Initialization Failed: Disabling Hotpatch functionality.
1.516: In Function TestVolatileFlag, line 12013, RegOpenKeyEx failed with error 0x2
1.516: In Function TestVolatileFlag, line 12045, RegOpenKeyEx failed with error 0x2
1.516: DoInstallation: CleanPFR failed: 0x2 
1.516: In Function GetBuildType, line 1170, RegQueryValueEx failed with error 0x2
1.516: SetProductTypes: InfProductBuildType=BuildType.Sel
1.531: SetAltOsLoaderPath: No section uses DirId 65701; done.
1.594: DoInstallation: FetchSourceURL for c:\52fa1b1dbf5491ca582ac4\Update\update_wxp.inf failed
1.594: CreateUninstall = 1,Directory = C:\WINDOWS\$NtUninstallKB943729$ 
1.594: LoadFileQueues: UpdSpGetSourceFileLocation for halmacpi.dll failed: 0xe0000102
1.594: BuildCabinetManifest: update.url absent
1.594: Starting AnalyzeComponents
1.594: AnalyzePhaseZero used 0 ticks
1.594: No c:\windows\INF\updtblk.inf file.
1.594: OEM file scan used 0 ticks
1.594: AnalyzePhaseOne: used 0 ticks
1.594: AnalyzeComponents: Hotpatch analysis disabled; skipping.
1.594: AnalyzeComponents: Hotpatching is disabled.
1.625: AnalyzePhaseTwo used 15 ticks
1.625: AnalyzePhaseThree used 0 ticks
1.625: AnalyzePhaseFive used 0 ticks
1.625: AnalyzePhaseSix used 0 ticks
1.625: AnalyzeComponents used 31 ticks
1.625: Downloading 0 files
1.625: bPatchMode = FALSE
1.625: Inventory complete: ReturnStatus=0, 31 ticks
1.625: Num Ticks for invent : 31
1.625: Allocation size of drive C: is 4096 bytes, free space = 40797515776 bytes
1.641: AnalyzeDiskUsage:  Skipping EstimateDiskUsageForUninstall.
1.641: Drive C: free 38907MB req: 8MB w/uninstall: NOT CALCULATED.
1.641: CabinetBuild complete
1.641: Num Ticks for Cabinet build : 16
1.641: DynamicStrings section not defined or empty.
1.641: Starting process:  msiexec /x {376B771D-8C14-4AFF-874B-677C3423F8F8} /quiet
2.172:  Return Code = 1605 
2.172: Starting process:  msiexec /x {5A01A639-CF6C-441D-9EF3-B59C4375FF87} /quiet
2.406:  Return Code = 1605 
2.406: Starting process:  msiexec /x {337240B1-42C2-4384-AAFF-D347A6D2CC5E} /quiet
2.641:  Return Code = 1605 
2.641: Starting process:  msiexec /x {362C838B-54FF-4197-847B-8927FF1742EE} /quiet
2.875:  Return Code = 1605 
2.875: Starting process:  msiexec /x {E606D790-404B-46F7-8DE6-C1FAE06CAC67} /quiet
3.219:  Return Code = 1605 
3.219: Starting process:  msiexec /x {4583EB96-6167-4B87-8F0E-A12A128B3EB0} /quiet
3.453:  Return Code = 1605 
3.453: Starting process:  msiexec /x {200B6216-5FA0-4DAA-BC41-500CE1ADCF97} /quiet
3.688:  Return Code = 1605 
3.688: Starting process:  msiexec /x {B01ED954-EB4F-401F-9CDE-98895FE6F367} /quiet
3.906:  Return Code = 1605 
3.906: Starting process:  msiexec /x {2765750D-7888-4D77-AD27-A71EC00AFF53} /quiet
4.141:  Return Code = 1605 
4.141: Starting process:  msiexec /x {D787C24E-809D-4C48-BF53-EC5C76689A13} /quiet
4.375:  Return Code = 1605 
4.391: FileInUse:: Detection disabled.
5.391: LoadFileQueues: UpdSpGetSourceFileLocation for halmacpi.dll failed: 0xe0000102
5.516: Num Ticks for Backup : 3875
5.578: Num Ticks for creating uninst inf : 62
5.578: Registering Uninstall Program for -> KB943729, KB943729 , 0x0
5.625: LoadFileQueues: UpdSpGetSourceFileLocation for halmacpi.dll failed: 0xe0000102
7.266: System Restore Point set.
7.297: Copied file:  C:\WINDOWS\system32\spmsg.dll
9.000: PFE2: Not avoiding Per File Exceptions.
9.047: GetCatVersion:  Failed to retrieve version information from C:\WINDOWS\system32\CatRoot\{F750E6C3-38EE-11D1-85E5-00C04FC295EE}\KB943729.cat with error 0x57
9.328: Copied file:  C:\WINDOWS\system32\gpprefcl.dll
9.485: Copied file:  C:\WINDOWS\system32\WBEM\polprocl.mof
9.547: Copied file:  C:\WINDOWS\system32\WBEM\polprocl.mfl
9.578: Copied file:  C:\WINDOWS\system32\WBEM\POLBASE.MOF
9.610: Copied file:  C:\WINDOWS\system32\WBEM\POLPRO.MOF
9.641: Copied file:  C:\WINDOWS\system32\WBEM\POLPROC.MOF
9.656: Copied file:  C:\WINDOWS\system32\WBEM\POLPROU.MOF
9.672: DoInstallation: Installing assemblies with source root path: c:\52fa1b1dbf5491ca582ac4\
9.672: Num Ticks for Copying files : 4094
9.969: Num Ticks for Reg update and deleting 0 size files : 297	
9.969: Starting process:  C:\WINDOWS\system32\wbem\mofcomp.exe C:\WINDOWS\system32\wbem\polprocl.mof
10.813:  Return Code = 0 
13.953: UpdateSpUpdSvcInf: Source [ProcessesToRunAfterReboot] section is empty; nothing to do.
13.985: RebootNecessary = 0,WizardInput = 1 , DontReboot = 1, ForceRestart = 0

-------
С Уважением,
Пётр Ластенко.


Отправлено: 22:04, 02-07-2012 | #16