Question

On startup check if a Mspatch is there else install it according to the OS.

Asked by: bsharath

Hi,

On startup check if a Mspatch is there else install it according to the OS.
If os xp a different patch if Win 2003 then different if t then diff if Vista then diff if Win 2008 then another
If installed then log the time and date of the installation and the machine name to a log file in the UNC.
This installation should be 10% silent on the user end.

Can anyone help with a login script please

regards
Sharath

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-17 at 14:43:22ID24820950
Tags

Script

,

Bat

,

vbs

Topics

Scripting Languages

,

Windows Batch Scripting

,

VB Script

Participating Experts
3
Points
500
Comments
98

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Silent running command
    hi, i have batch file calling EXE file from the server how to run this file (command) using silent mode. Note : i don't want the user to know what files are running or commands ( i don't want to copy this files on users pc ) just i want to run the batch file in silent mode...
  2. Script to use as a startup script to delete all files from the re…
    Hi, Script to use as a startup script to delete all files from the recycle bin on all drives if exists and record them into 1 log file in a UNC path. On startup when run clear the files within the recycle bin and record the filenames & size to the log in the UNC regard...
  3. Startup script that can check every service if there is a alte…
    Hi, Startup script that can check every service if there is a alternative user account set to run. if yes then record the Details to a UNC log file. Log file like Machinename - Service name- Account name Can anyone help with a script that can do this with double checking on...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ram_keralaPosted on 2009-10-18 at 09:23:10ID: 25600345

Following link is an advanced way of installing hotfixes based on OS SP Level and version

Please let me know if you have queries in script, i will be able to assist you

http://www.rlmueller.net/PatchInstall.htm

 

by: bsharathPosted on 2009-10-18 at 09:36:54ID: 25600402

Thank U.
Can this be changed as a startup script. if not present install else omit
And where all should i make the changes

 

by: RobSampsonPosted on 2009-10-18 at 18:15:22ID: 25602166

Hi, I've stripped out the bits from that script that aren't required for running it against one computer, so this will hopefully work as a StartUp script.

Regards,

Rob.

Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine "Failed to connect to WMI on " & strComputer
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		' Install the patch on the computer
		objLogFile.WriteLine "Installing patch " & strCorrectPatch
		On Error Resume Next
		' Start the installation without user interaction,
		' and force a restart after completion.
		intReturnCode = objShell.Run "cmd /c """ & strCorrectPath & """ -q -f", 0, True)
		If intReturnCode <> 0 Then
			objLogFile.WriteLine "Failed to install on " & strComputer
		Else
			objLogFile.WriteLine "Installation successful on " & strComputer
		End If
    End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:

Select allOpen in new window

 

by: RobSampsonPosted on 2009-10-18 at 18:16:43ID: 25602169

Oh, that doesn't check if the patch exists first....I'll fix that when I get time to, in a few hours.

Rob.

 

by: RobSampsonPosted on 2009-10-18 at 20:03:08ID: 25602410

OK, now it checks if the patch specified by strPatchNumber is already installed before starting it.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "931906"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
strLogFile = "PatchLog.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine "Failed to connect to WMI on " & strComputer
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
		ElseIf boolPatchInstalled = False Then
			' Install the patch on the computer
			objLogFile.WriteLine "Installing patch " & strCorrectPatch
			On Error Resume Next
			' Start the installation without user interaction,
			' and force a restart after completion.
			intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q -f", 0, True)
			If intReturnCode <> 0 Then
				objLogFile.WriteLine "Failed to install on " & strComputer
			Else
				objLogFile.WriteLine "Installation successful on " & strComputer
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine strCorrectPatch & " is already installed on " & strComputer & "."
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-18 at 22:50:56ID: 25602819

 

by: bsharathPosted on 2009-10-18 at 23:38:59ID: 25602958

Thanks Rob for Vista and 2008 i have Msu extension files. how can i run them silently and for exe's how can i have a silent install

 

by: bsharathPosted on 2009-10-19 at 03:49:06ID: 25604023

Rob and what happend when a OS say Win 7 does not have a patch to be installed will it error. Hope it will be skipped.?

 

by: RobSampsonPosted on 2009-10-22 at 23:20:39ID: 25641678

If you leave, for example,

' Request Windows 7 client patch file.
strPatchWindows7 = ""

so that it's empty for that OS, it will not try to install anything.

For EXE's, it uses
<name>.exe -q -f

for MSU, MSI, or MSP is uses
<name>.<ext> /quiet /forcerestart


Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "931906"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
strLogFile = "PatchLog.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine "Failed to connect to WMI on " & strComputer
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
		ElseIf boolPatchInstalled = False Then
			' Install the patch on the computer
			objLogFile.WriteLine "Installing patch " & strCorrectPatch
			On Error Resume Next
			' Start the installation without user interaction,
			' and force a restart after completion.
			If LCase(Right(strCorrectPath, 4)) = ".exe" Then
				intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q -f", 0, True)
			ElseIf LCase(Right(strCorrectPath, 4)) = ".msu" Or LCase(Right(strCorrectPath, 4)) = ".msp" Or LCase(Right(strCorrectPath, 4)) = ".msi" Then
				intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ /quiet /forcerestart", 0, True)
			End If
			If intReturnCode <> 0 Then
				objLogFile.WriteLine "Failed to install on " & strComputer
			Else
				objLogFile.WriteLine "Installation successful on " & strComputer
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine strCorrectPatch & " is already installed on " & strComputer & "."
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-23 at 08:03:04ID: 25645073

Thanks Rob..Can i not have a restart after install?
I dont wnat a restart
and
There is a log file create on the local machine. Can just one log be create on the UNC path.
Can the log be generated on each startup....
With machine name and patch installed data

 

by: TechnoChatPosted on 2009-10-25 at 14:29:07ID: 25658426

If you don't want to restart the system after installing the patch use following syntax for MSU, MSI, or MSP
<name>.<ext> /quiet /norestart

Or you can get detail information about silent switches on following location

http://unattended.sourceforge.net/installers.php

Thanks

 

by: RobSampsonPosted on 2009-10-25 at 17:37:41ID: 25659158

That's correct, this section:

                  If LCase(Right(strCorrectPath, 4)) = ".exe" Then
                        intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q -f", 0, True)
                  ElseIf LCase(Right(strCorrectPath, 4)) = ".msu" Or LCase(Right(strCorrectPath, 4)) = ".msp" Or LCase(Right(strCorrectPath, 4)) = ".msi" Then
                        intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ /quiet /forcerestart", 0, True)
                  End If


can be changed to this

                  If LCase(Right(strCorrectPath, 4)) = ".exe" Then
                        intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q", 0, True)
                  ElseIf LCase(Right(strCorrectPath, 4)) = ".msu" Or LCase(Right(strCorrectPath, 4)) = ".msp" Or LCase(Right(strCorrectPath, 4)) = ".msi" Then
                        intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ /quiet /norestart", 0, True)
                  End If



where I've removed the /f for EXEs and change /forcerestart to /norestart for the others.

Regards,

Rob.

 

by: bsharathPosted on 2009-10-25 at 19:33:05ID: 25659434

 

by: bsharathPosted on 2009-10-25 at 19:55:31ID: 25659489

Rob i just tested on a win 2003 machine. First i tried installing on a machine where the patch was available. I got its available. Then removed it restarted the machine and tried and i got this message

\\indphos\InterChk\Ms_Patch\Win2003-32_bit\WindowsServer2003-KB958644-x86-ENU.exe -q is already installed on DEVCS161.

Installing patch \\indphos\InterChk\Ms_Patch\Win2003-32_bit\WindowsServer2003-KB958644-x86-ENU.exe -q
Installation successful on DEVCS161

But cannot see in Add/Remove programs
How many ever times i run i get as its installing and its installed successful

 

by: bsharathPosted on 2009-10-25 at 19:57:26ID: 25659493

And i want a UNC log only and no local log.... If the Patch is already available dont write into log. Only if its not there and it installs Log the details with date and time.
If it for some reason fails then log the details to the UNC log

 

by: RobSampsonPosted on 2009-10-25 at 22:03:07ID: 25659735

OK, try this.

Note that the patch paths given by
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"


should *not* include any switches.  The switches are automatically appended later.  The paths above should be only the file path.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "931906"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine "Failed to connect to WMI on " & strComputer
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
		ElseIf boolPatchInstalled = False Then
			' Install the patch on the computer
			objLogFile.WriteLine "Installing patch " & strCorrectPatch
			On Error Resume Next
			' Start the installation without user interaction,
			' and force a restart after completion.
			If LCase(Right(strCorrectPath, 4)) = ".exe" Then
				intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q", 0, True)
			ElseIf LCase(Right(strCorrectPath, 4)) = ".msu" Or LCase(Right(strCorrectPath, 4)) = ".msp" Or LCase(Right(strCorrectPath, 4)) = ".msi" Then
				intReturnCode = objShell.Run("cmd /c msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """", 0, True)
			End If
			If intReturnCode <> 0 Then
				objLogFile.WriteLine "Failed to install on " & strComputer
			Else
				objLogFile.WriteLine "Installation successful on " & strComputer
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			'objLogFile.WriteLine strCorrectPatch & " is already installed on " & strComputer & "."
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-25 at 22:15:17ID: 25659758

Thanks
But the log even when the patch is available i get this
Installation successful on IN-1
Instead i need to get as available

 

by: bsharathPosted on 2009-10-25 at 22:17:03ID: 25659764

Still does not install if patch not there but the log shows as installed

 

by: RobSampsonPosted on 2009-10-25 at 22:22:18ID: 25659788

Have you got
strPatchNumber = "931906"

correct?  If you go to HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
and search for the number you use as strPatchNumber, that needs to be found in the registry. That is how it searches for the patch.

Regards,

Rob.

 

by: bsharathPosted on 2009-10-25 at 22:27:47ID: 25659810

I have this patch "958644"
Attached screenshot shows its not having an entry in the registry

 

by: RobSampsonPosted on 2009-10-25 at 22:35:50ID: 25659834

So the above screenshot is from Add / Remove programs?  I'll have to use another method instead of the registry to see if it already exists then.  I'll try to have that working tomorrow.

Regards,

Rob.

 

by: bsharathPosted on 2009-10-25 at 22:37:22ID: 25659839

No screenshot is from Registry...
Ok Thanks

 

by: RobSampsonPosted on 2009-10-25 at 22:57:22ID: 25659891

Oh, so it *is* in the registry, under the key I mentioned?  That means that the script should be able to detect that it has been installed. Anyway, I'll test it again tomorrow.

Rob.

 

by: bsharathPosted on 2009-10-25 at 22:59:50ID: 25659899

Yes its the location
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

 

by: bsharathPosted on 2009-10-26 at 06:43:36ID: 25662127

Rob i will need the date and time of the installation if done. And Record just where installation took place and not where its already available

 

by: bsharathPosted on 2009-10-27 at 22:11:30ID: 25680088

Hi Rob just a reminder...:-)

 

by: RobSampsonPosted on 2009-10-29 at 21:36:54ID: 25700200

Hi Sharath,

This should now work. I have tested it, and found a few problems that made it not work for you.

It will log a bit of info, so any lines that you do not want in the log, you can find that line in the script and just comment it out.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "942763"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
strLogFile = "PatchInstallLog.txt"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine Now & ": " & strComputer & " - Failed to connect to WMI"
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - Unable to determine if " & strCorrectPatch & " is already installed"
		ElseIf boolPatchInstalled = False Then
			If objFSO.FileExists(strCorrectPatch) = True Then
				' Install the patch on the computer
				objLogFile.WriteLine Now & ": " & strComputer & " - Installing patch " & strCorrectPatch
				On Error Resume Next
				' Start the installation without user interaction,
				' and force a restart after completion.
				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					intReturnCode = objShell.Run("cmd /c """ & strCorrectPatch & """ -q", 0, True)
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msu" Or LCase(Right(strCorrectPatch, 4)) = ".msp" Or LCase(Right(strCorrectPatch, 4)) = ".msi" Then
					intReturnCode = objShell.Run("cmd /c msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """", 0, True)
				End If
				'If intReturnCode <> 0 Then
					'objLogFile.WriteLine Now & ": " & strComputer & " - Failed to start install"
				'Else
					'objLogFile.WriteLine Now & ": " & strComputer & " - Started installation"
				'End If
				boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
				If boolPatchInstalled = True Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation successful"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation failed"
				End If
			Else
				objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " was not found. Cannot install patch."
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " is already installed"
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-29 at 21:44:55ID: 25700223

Thanks Rob will this line save the file in each machine

strLogFile = "PatchInstallLog.txt"
If yes can i comment it

 

by: RobSampsonPosted on 2009-10-29 at 21:47:08ID: 25700228

Oh yeah, sorry, that was for my testing too.  The line above it can be used instead
strLogFile = "\\server\share\PatchInstallOnStartup.log"

so the line you mentioned can be deleted.

Regards,

Rob.

 

by: bsharathPosted on 2009-10-29 at 22:03:20ID: 25700268

On a vista machine i get this

10/30/2009 10:32:39 AM: R2-VBDB01 - Installing patch \\sophos\InterChk\Mspatch\Windows6.0-KB958644-x86.msu
10/30/2009 10:32:40 AM: R2-VBDB01 - Installation failed

 

by: RobSampsonPosted on 2009-10-29 at 22:18:25ID: 25700314

Oh, would that be because of UAC?  If you disable UAC, does that help?

If UAC is the problem, we may need to try using the Elevate powertoy to run the install. Do you already have that downloaded?

Set strElevatePowerToy = "<file>" to suit where you have Elevate.exe and see if this works for Vista.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "942763"
 
strElevatePowertoy = "\\server\share\elevate.exe"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine Now & ": " & strComputer & " - Failed to connect to WMI"
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - Unable to determine if " & strCorrectPatch & " is already installed"
		ElseIf boolPatchInstalled = False Then
			If objFSO.FileExists(strCorrectPatch) = True Then
				' Install the patch on the computer
				objLogFile.WriteLine Now & ": " & strComputer & " - Installing patch " & strCorrectPatch
				On Error Resume Next
				' Start the installation without user interaction,
				' and force a restart after completion.
				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = "cmd /c """ & strCorrectPatch & """ -q"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msu" Or LCase(Right(strCorrectPatch, 4)) = ".msp" Or LCase(Right(strCorrectPatch, 4)) = ".msi" Then
					strCommand = "cmd /c msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				End If
				If strCorrectPatch = strPatchVista Then
					strCommand = objFSO.GetFile(strElevatePowertoy).ShortPath & " " & strCommand
				End If
				intReturnCode = objShell.Run(strCommand, 0, True)
				'If intReturnCode <> 0 Then
					'objLogFile.WriteLine Now & ": " & strComputer & " - Failed to start install"
				'Else
					'objLogFile.WriteLine Now & ": " & strComputer & " - Started installation"
				'End If
				boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
				If boolPatchInstalled = True Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation successful"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation failed"
				End If
			Else
				objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " was not found. Cannot install patch."
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " is already installed"
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:

Select allOpen in new window

 

by: bsharathPosted on 2009-10-29 at 23:26:55ID: 25700511

Rob where can i download it. What is the exe name?

 

by: RobSampsonPosted on 2009-10-30 at 00:09:56ID: 25700628

You can download it here:
Elevate powertool for Windows vista
http://www.microsoft.com/technet/technetmag/issues/2007/06/UtilitySpotlight/default.aspx

Install it onto one machine, and you should then be able to copy the Elevate.exe file to a network share.

Regards,

Rob.

 

by: bsharathPosted on 2009-10-30 at 00:15:59ID: 25700658

In this path i have no exe's extracted
C:\Elevation

 

by: bsharathPosted on 2009-10-30 at 02:46:10ID: 25701379

I downloaded the exe from here and changed the paths accordingly

http://www.wintellect.com/CS/files/folders/sample_files/entry3385.aspx

Still get the failed message

I get this

C:\Program Files\Sophos Sweep for NT\Mspatch>Elevate.exe
Elevate 4.0.10326.0
(c) 2007 - John Robbins - www.wintellect.com

Execute a process on the command line with elevated rights on Vista

Usage: Elevate [-?|-wait|-k] prog [args]
   -?    - Shows this help
   -wait - Waits until prog terminates
   -k    - Starts the the %comspec% environment variable value and
           executes prog in it (CMD.EXE, 4NT.EXE, etc.)
   prog  - The program to execute
   args  - Optional command line arguments to prog

Note that because the way ShellExecute works, Elevate cannot set the
current directory for prog. Consequently, relative paths as args will
probably not work.

 

by: RobSampsonPosted on 2009-10-31 at 23:49:38ID: 25712832

In the Elevation folder that is created after downloading the file from here:
http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx

there is an Elevate.vbs and and Elevate.cmd file.

Copy both of those to the network folder, and change
strElevatePowertoy = "\\server\share\elevate.exe"

to this
strElevatePowertoy = "\\server\share\elevate.cmd"

Regards,

Rob.

 

by: bsharathPosted on 2009-11-01 at 01:39:45ID: 25713030

Rob i tried but does not install.
I even tried on a xp machine but no change

 

by: bsharathPosted on 2009-11-01 at 08:44:00ID: 25714286

Rob for Vista it works but not for Vista and win 2008

 

by: RobSampsonPosted on 2009-11-01 at 19:30:41ID: 25716924

On a Vista machine, if you manually run the following:
\\server\share\elevate.cmd cmd /c msiexec /i "\\server\share\Vista_Patch.msu" /norestart

what do you get?  I don't have a Vista machine, so I'll need to find out what works manually first, before we can automate it.

Regards,

Rob.

 

by: bsharathPosted on 2009-11-01 at 19:36:27ID: 25716946

I get this

[Window Title]
Windows Installer

[Main Instruction]
This installation package could not be opened.  Contact the application vendor to verify that this is a valid Windows Installer package.

[OK]

 

by: RobSampsonPosted on 2009-11-01 at 19:49:22ID: 25716975

Oh, that's strange.  Did it get corrupt when you downloaded it?  Can you try downloading that patch again, and running the same command?

Rob.

 

by: bsharathPosted on 2009-11-01 at 19:58:14ID: 25716996

Rob i did download a new copy and i get the same message. When i run the msu manually it does work

 

by: RobSampsonPosted on 2009-11-01 at 20:15:09ID: 25717034

OK, so MSU files use wusa.exe, not msiexec.exe - I learn something new every day.
http://support.microsoft.com/kb/934307

And it works for Vista and Server 2008.  Therefore, hopefully this works.

If the code doesn't work, the command it is running is
\\server\share\elevate.cmd cmd /c wusa "\\server\share\Vista_Patch.msu" /norestart

so try that and let me know what you get if the code doesn't work.

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "942763"
 
' The Elevate PowerToy requires Elevate.cmd and Elevate.vbs to be located in the same folder
strElevatePowertoy = "\\server\share\elevate.cmd"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine Now & ": " & strComputer & " - Failed to connect to WMI"
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - Unable to determine if " & strCorrectPatch & " is already installed"
		ElseIf boolPatchInstalled = False Then
			If objFSO.FileExists(strCorrectPatch) = True Then
				' Install the patch on the computer
				objLogFile.WriteLine Now & ": " & strComputer & " - Installing patch " & strCorrectPatch
				On Error Resume Next
				' Start the installation without user interaction,
				' and force a restart after completion.
				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = "cmd /c """ & strCorrectPatch & """ -q"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msu" Then
					strCommand = "cmd /c wusa """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msp" Or LCase(Right(strCorrectPatch, 4)) = ".msi" Then
					strCommand = "cmd /c msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				End If
				If strCorrectPatch = strPatchVista Then
					strCommand = objFSO.GetFile(strElevatePowertoy).ShortPath & " " & strCommand
				End If
				intReturnCode = objShell.Run(strCommand, 0, True)
				'If intReturnCode <> 0 Then
					'objLogFile.WriteLine Now & ": " & strComputer & " - Failed to start install"
				'Else
					'objLogFile.WriteLine Now & ": " & strComputer & " - Started installation"
				'End If
				boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
				If boolPatchInstalled = True Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation successful"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation failed"
				End If
			Else
				objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " was not found. Cannot install patch."
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " is already installed"
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-01 at 23:28:44ID: 25717546

When i try the whole statement

I get an error encountered..
---------------------------
Windows Update Standalone Installer
---------------------------
Installer encountered an error: 0x80070002

The system cannot find the file specified.
---------------------------
OK  
---------------------------

When i select just this
\\hos\InterChk\Mspatch\elevate.cmd

I get this


---------------------------
Windows Script Host
---------------------------
Elevate - Elevation Command Line Tool for Windows Vista



Purpose:

--------

To launch applications that prompt for elevation (i.e. Run as Administrator)

from the command line, a script, or the Run box.

Usage:  

    elevate application <arguments>

Sample usage:

    elevate notepad "C:\Windows\win.ini"

    elevate cmd /k cd "C:\Program Files"

    elevate powershell -NoExit -Command Set-Location 'C:\Windows'

Usage with scripts: When using the elevate command with scripts such as

Windows Script Host or Windows PowerShell scripts, you should specify

the script host executable (i.e., wscript, cscript, powershell) as the

application.

Sample usage with scripts:

    elevate wscript "C:\windows\system32\slmgr.vbs" dli

    elevate powershell -NoExit -Command & 'C:\Temp\Test.ps1'

The elevate command consists of the following files:

    elevate.cmd

    elevate.vbs

---------------------------
OK  
---------------------------


 

by: RobSampsonPosted on 2009-11-02 at 20:38:18ID: 25726088

Hmmm, so elevate is working, and it seems that wusa cannot find the patch file.
From a command prompt, if you run this
wusa "\\server\share\Vista_Patch.msu" /norestart

you need the patch to install to start.  When you ran it before, are you sure that the path to the MSU file was correct?

Rob.

 

by: bsharathPosted on 2009-11-02 at 21:00:49ID: 25726169

Checking on this Rob...I think some install problem.
Can you help on this
http://www.experts-exchange.com/Programming/Languages/Q_24861826.html

 

by: bsharathPosted on 2009-11-03 at 01:02:35ID: 25727102

Rob i did some testing and have come to this conclusion

When there is a Patch already installed and i try this command

wusa "\\t-dsm\logs\Mspatch\Windows6.0-KB958644-x86.msu" /norestart

I get this

---------------------------
Windows Update Standalone Installer
---------------------------
The update does not apply to your system


---------------------------
OK  
---------------------------


And the startup shows

11/3/2009 2:25:32 PM: DS050 - Installing patch \\t-dsm\logs\Mspatch\Windows6.0-KB958644-x86.msu
11/3/2009 2:25:33 PM: DS050 - Installation failed

The whole above senario is when there is a patch installed and it tries. So for such cases it needs to record the log as. Already available.


When i run this when there is no patch it properly installs
wusa "\\t-dsm\logs\Mspatch\Windows6.0-KB958644-x86.msu" /norestart

 

by: RobSampsonPosted on 2009-11-03 at 21:44:53ID: 25736717

Hmmm, OK, that's good info.  If we go back to use WUSA.exe, and not use Elevate.cmd, does this work?

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "942763"
 
' The Elevate PowerToy requires Elevate.cmd and Elevate.vbs to be located in the same folder
strElevatePowertoy = "\\server\share\elevate.cmd"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine Now & ": " & strComputer & " - Failed to connect to WMI"
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - Unable to determine if " & strCorrectPatch & " is already installed"
		ElseIf boolPatchInstalled = False Then
			If objFSO.FileExists(strCorrectPatch) = True Then
				' Install the patch on the computer
				objLogFile.WriteLine Now & ": " & strComputer & " - Installing patch " & strCorrectPatch
				On Error Resume Next
				' Start the installation without user interaction,
				' and force a restart after completion.
				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = "cmd /c """ & strCorrectPatch & """ -q"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msu" Then
					strCommand = "cmd /c wusa """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msp" Or LCase(Right(strCorrectPatch, 4)) = ".msi" Then
					strCommand = "cmd /c msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				End If
				'If strCorrectPatch = strPatchVista Then
				'	strCommand = objFSO.GetFile(strElevatePowertoy).ShortPath & " " & strCommand
				'End If
				intReturnCode = objShell.Run(strCommand, 0, True)
				'If intReturnCode <> 0 Then
					'objLogFile.WriteLine Now & ": " & strComputer & " - Failed to start install"
				'Else
					'objLogFile.WriteLine Now & ": " & strComputer & " - Started installation"
				'End If
				boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
				If boolPatchInstalled = True Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation successful"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation failed"
				End If
			Else
				objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " was not found. Cannot install patch."
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " is already installed"
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-03 at 22:09:08ID: 25736815

Still get the same failed message

11/4/2009 11:38:13 AM: DEV-DCS039 - Installing patch \\in-dsm\logs\Mspatch\Windows6.0-KB958644-x86.msu
11/4/2009 11:38:13 AM: DEV--DCS039 - Installation failed

 

by: RobSampsonPosted on 2009-11-05 at 22:11:21ID: 25756944

Sharath, we just built a Windows 7 machine, so I grabbed it for a quick test. I was able to run this:
\\server\share\elevate.cmd wusa "\\server\share\Patch.msu" /norestart

and it started, although I did get "The update does not apply to your system".

But that's OK, because at least we know the install started.  Vista should be the same.  I'm also guessing that Server 2008 has the same behaviour as well.  So, see if this works.

Also a reminder, make sure you change strPatchNumber to the number of the patch that would be found in Add / Remove Programs if it was installed (usually just the KB number).

Regards,

Rob.

Const HKEY_LOCAL_MACHINE = &H80000002
Set objNetwork = CreateObject("Wscript.Network")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Const intForAppending = 8
Set objShell = CreateObject("Wscript.Shell")
 
strPatchNumber = "942763"
 
' The Elevate PowerToy requires Elevate.cmd and Elevate.vbs to be located in the same folder
strElevatePowertoy = "\\server\share\elevate.cmd"
 
' Request W2k client patch file.
strPatchW2k = "\\server\share\Win2K_Patch.exe"
 
' Request XP client patch file.
strPatchXP = "\\server\share\WinXP_Patch.exe"
 
' Request W2k3 client patch file.
strPatchW2k3 = "\\server\share\Win2K3_Patch.exe"
 
' Request Vista client patch file.
strPatchVista = "\\server\share\WinVista_Patch.exe"
 
' Request Win2008 client patch file.
strPatchWin2008 = "\\server\share\Win2008_Patch.exe"
 
' Request Windows 7 client patch file.
strPatchWindows7 = "\\server\share\Windows7_Patch.exe"
 
strLogFile = "\\server\share\PatchInstallOnStartup.log"
 
strComputer = objNetwork.ComputerName
 
' Open log file.
Set objLogFile = objFSO.OpenTextFile(strLogFile, intForAppending, True)
On Error Resume Next
Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If Err.Number <> 0 Then
	On Error GoTo 0
	'Wscript.Echo "Failed to connect to WMI on " & strComputer & "."
	objLogFile.WriteLine Now & ": " & strComputer & " - Failed to connect to WMI"
	Err.Clear
Else
	On Error GoTo 0
	strCorrectPatch = DetectOS(objWMI)
	If (strCorrectPatch <> "") Then
		boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
		If boolPatchInstalled = "Error" Then
			'Wscript.Echo "Unable to determine if " & strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - Unable to determine if " & strCorrectPatch & " is already installed"
		ElseIf boolPatchInstalled = False Then
			If objFSO.FileExists(strCorrectPatch) = True Then
				' Install the patch on the computer
				objLogFile.WriteLine Now & ": " & strComputer & " - Installing patch " & strCorrectPatch
				On Error Resume Next
				' Start the installation without user interaction,
				' and force a restart after completion.
				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = """" & strCorrectPatch & """ -q"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msu" Then
					strCommand = "wusa """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				ElseIf LCase(Right(strCorrectPatch, 4)) = ".msp" Or LCase(Right(strCorrectPatch, 4)) = ".msi" Then
					strCommand = "msiexec /i """ & strCorrectPatch & """ /quiet /norestart /li+ """ & strLogFile & """"
				End If
				If strCorrectPatch = strPatchVista Or strCorrectPatch = strPatchWindows7 Or strCorrectPatch = strPatchWin2008 Then
					strCommand = objFSO.GetFile(strElevatePowertoy).ShortPath & " " & strCommand
				End If
				intReturnCode = objShell.Run(strCommand, 0, True)
				If intReturnCode <> 0 Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Failed to start install"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Started installation"
				End If
				boolPatchInstalled = CheckIfPatchInstalled(strComputer, strPatchNumber)
				If boolPatchInstalled = True Then
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation successful"
				Else
					objLogFile.WriteLine Now & ": " & strComputer & " - Installation failed"
				End If
			Else
				objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " was not found. Cannot install patch."
			End If
		Else
			'Wscript.Echo strCorrectPatch & " is already installed on " & strComputer & "."
			objLogFile.WriteLine Now & ": " & strComputer & " - " & strCorrectPatch & " is already installed"
	    End If
	End If
End If
objLogFile.Close
 
Function DetectOS(objRemote)
	Dim objOSInfo, objOperatingSystem, strSystemType
	strSystemType = ""
	Set objOSInfo = objRemote.InstancesOf("Win32_OperatingSystem")
	' Only one instance is ever returned (the currently active OS).
	For Each objOperatingSystem In objOSInfo
		If InStr(objOperatingSystem.Caption, "2000") > 0 Then
			' Windows 2000 SP2, SP3, SP4.
			strSystemType = strPatchW2k
		ElseIf InStr(objOperatingSystem.Caption, "XP") > 0 Then
			' Windows XP RTM, SP1.
			strSystemType = strPatchXP
		ElseIf InStr(objOperatingSystem.Caption, "2003") > 0 Then
			' Windows Server 2003
			strSystemType = strPatchW2k3
		ElseIf InStr(objOperatingSystem.Caption, "Vista") > 0 Then
			' Windows Vista
			strSystemType = strPatchVista
		ElseIf InStr(objOperatingSystem.Caption, "2008") > 0 Then
			' Windows Server 2008
			strSystemType = strPatchWin2008
		ElseIf InStr(objOperatingSystem.Caption, "Windows 7") > 0 Then
			' Windows 7
			strSystemType = strPatchWindows7
		End If
	Next
	DetectOS = strSystemType
End Function
 
Function CheckIfPatchInstalled(strComputer, strPatchNumber)
	boolInstalled = False
	strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"	
	On Error Resume Next
	Set objRegistry = GetObject("winmgmts:" & _
		"{impersonationLevel=Impersonate}!\\" & _
		strComputer & "\root\default:StdRegProv")
	If Err.Number <> 0 Then
		boolInstalled = "Error"
		Err.Clear
		On Error GoTo 0
	Else
		objRegistry.EnumKey HKEY_LOCAL_MACHINE, strKey, arrSubKeys
		On Error Resume Next
		For Each strSubKey In arrSubKeys
			If Err.Number = 0 Then
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayName", strDisplayName
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "DisplayVersion", strDisplayVersion
				objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKey & "\" & strSubKey, "InstallLocation", strInstallLocation
		
				'strAllDetails = strAllDetails & strComputer & ";" & strSubKey & ";" & strDisplayName & ";" & strDisplayVersion & VbCrLf
				If InStr(strDisplayName, "KB") > 0 And InStr(strDisplayName, strPatchNumber) > 0 Then
					boolInstalled = True
					Exit For
				End If
			
				strDisplayName = vbEmpty
				strDisplayVersion = vbEmpty
				strInstallLocation = vbEmpty
			Else
				boolIntstalled = "Error"
				Err.Clear
				Exit For
			End If
		Next
	End If
	CheckIfPatchInstalled = boolInstalled
End Function

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:

Select allOpen in new window

 

by: bsharathPosted on 2009-11-05 at 22:46:43ID: 25757109

I get this

11/6/2009 12:15:35 PM: D306 - Installing patch \\insm\logs\Mspatch\Windows6.0-KB958644-x86.msu
11/6/2009 12:15:36 PM: D306 - Started installation
11/6/2009 12:15:37 PM: D306 - Installation failed

 

by: RobSampsonPosted on 2009-11-06 at 02:33:31ID: 25757964

I think that might be correct though.  When you attempt to install it manually, and get "The update does not apply to your system", that will effectively fail, as the last line states.

Is that the case?

Rob.

 

by: bsharathPosted on 2009-11-08 at 08:24:42ID: 25770893

If it fails can it be like in the log it writes as "Already installed"

 

by: RobSampsonPosted on 2009-11-09 at 20:31:07ID: 25782428

It will only write "Already installed" if the patch *is* already installed.  If it fails because of the "The update does not apply to your system", then that's a different reason I think.

Rob.

 

by: bsharathPosted on 2009-11-15 at 19:17:42ID: 25827633

Thanks Rob...

 

by: bsharathPosted on 2010-08-11 at 23:47:24ID: 33417215

Hi Rob can i use this to install Windows Xp sp3?
I tried changing the path name and installer path but did not work?

 

by: RobSampsonPosted on 2010-08-11 at 23:55:39ID: 33417258

No....SP3 does not have a display name or kb number in the registry.....this script only looks for the KB number in the display name.

Rob.

 

by: RobSampsonPosted on 2010-08-11 at 23:56:50ID: 33417263

No... SP3 does not have a display name or KB number in the registry....this script only looks for the KB number in the DisplayName value in the registry....

Rob.

 

by: bsharathPosted on 2010-08-12 at 00:01:25ID: 33417281

Hmm any other way to install Xp3?

 

by: RobSampsonPosted on 2010-08-12 at 00:13:08ID: 33417325

Yeah, there's a few....If you had a WSUS server, you could just use that to push it out....

Following instructions here (SP2 deployment has not changed for SP3):

http://technet.microsoft.com/en-us/library/bb457085.aspx

You would first run

XPsp3.exe / X:C:\ExtractedSP3

to extact the service pack. Then copy it to a network location.

Then, at StartUp, you would run

\\server\share\SP3\XPSp3.exe /O /norestart /quiet

Bare in mine the SP3 install takes AGES!

Regards,

Rob.

 

by: bsharathPosted on 2010-08-12 at 00:17:32ID: 33417350

Can this be run remotely i have no wsus for this site

 

by: bsharathPosted on 2010-08-15 at 22:20:28ID: 33443303

Hi Rob any views...

 

by: RobSampsonPosted on 2010-08-15 at 23:00:59ID: 33443417

Yes, you should be able to run

psexec -accepteula -u domain\administrator -p password -e \\RemotePC cmd /c \\server\share\SP3\XPSP3.exe /O /norestart /quiet

for each computer....

Rob.

 

by: bsharathPosted on 2010-08-16 at 00:45:54ID: 33443816

Thanks Rob it works
Can i run it on multiple at same time

 

by: RobSampsonPosted on 2010-08-17 at 21:01:03ID: 33461192

Probably best just to use

psexec -accepteula -u domain\administrator -p password -e \\@RemovePCs.txt cmd /c \\server\share\SP3\XPSP3.exe /O /norestart /quiet

For monitoring, try using the Microsoft Baseline Security Analyzer (MBSA) to tell you which machines don't have SP3.

Regards,

Rob.

 

by: RobSampsonPosted on 2010-08-17 at 21:03:55ID: 33461199

Probably best just to use

psexec -accepteula -u domain\administrator -p password -e \\@RemotePCs.txt cmd /c \\server\share\SP3\XPSP3.exe /O /norestart /quiet

where you specify @RemotePCs.txt for a list of computer names.

Then, for monitoring, run the Microsoft Baseline Security Analyzer (MBSA) to see which computers do not have SP3 installed.

Regards,

Rob.

 

by: bsharathPosted on 2010-08-17 at 21:06:03ID: 33461210

Thanks Rob i was using this . But one completes and then goes to another
Via psexec is there no switch to run multiple

 

by: RobSampsonPosted on 2010-08-17 at 21:10:40ID: 33461232

Does it make any difference if you add the -d switch, to cause it to not wait for it to finish?

psexec -accepteula -d -u domain\administrator -p password -e \\@RemotePCs.txt cmd /c \\server\share\SP3\XPSP3.exe /O /norestart /quiet

 

by: bsharathPosted on 2010-08-17 at 21:26:53ID: 33461288

Thanks Rob i guess its working. I get these different Id's for each machines. What does this mean.

I checked the share sessions and all the machines have a session established
with process ID 4400.
with process ID 3316.
with process ID 432.
with process ID 2972.
with process ID 2456.
with process ID 2040.

 

by: RobSampsonPosted on 2010-08-17 at 21:28:24ID: 33461295

Because it's no longer waiting for the process to finish, it's just returning the process ID of the remote process that was launched for each computer.

 

by: bsharathPosted on 2010-08-17 at 21:31:04ID: 33461306

Ok Rob thanks i think its working
Will confirm after few hrs. Once all machines are done..
:-)

 

by: bsharathPosted on 2011-11-06 at 22:21:41ID: 37092459

Hi Rob

need to run this patch. its a Msi and has accept etc screens while i do it manually

http://support.microsoft.com/kb/2588513

Will this script work in this case?

 

by: RobSampsonPosted on 2011-11-07 at 14:29:13ID: 37097129

It certainly should.   The script automatically adds these switches:
/quiet /norestart /li+ <logfile>

for MSI files, so it should install silently.  If you test this command manually on a machine, and it works, the script should work as well:
msiexec /i "\\server\share\YourPatch.msi" /quiet /norestart /li+ "\\server\share\YourLogFile.txt"

Regards,

Rob.

 

by: bsharathPosted on 2011-11-09 at 02:09:50ID: 37106086

Thanks Rob

can i install this patch with this script?

http://support.microsoft.com/kb/821277
http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=18384


Also can i use this for Sql Sp3?
if no can you give me something that can do this as well
As the above patch prequesite is Sp3

 

by: RobSampsonPosted on 2011-11-09 at 14:37:23ID: 37110890

It should if you change this

				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = """" & strCorrectPatch & """ -q"
                                              
1:
2:

Select allOpen in new window



to this

				If LCase(Right(strCorrectPatch, 4)) = ".exe" Then
					strCommand = """" & strCorrectPatch & """ /s /a /q"
                                              
1:
2:

Select allOpen in new window



You might need to add INSTANCENAME, BLANKSAPWD=1, or SAPWD arguments to specify your database instance and SA Password, but I'm not sure.

You might like to try it manually from a DOS prompt using
SQL2000-KB815495-8.00.0818-ENU.exe /s /a INSTANCENAME=<servername>

and also add BLANKSAPWD=1 *or* SAPWD=<yoursapwd> depending on whether you have one or not.

Then, if that works, add those arguments to the strCommand above.  If your instance is always your server name, then try something like:
                              strCommand = """" & strCorrectPatch & """ /s /a /q INSTANCENAME=" & strComputer &" SAPWD=YourSAPWD"

Regards,

Rob.

 

by: bsharathPosted on 2011-11-09 at 18:21:49ID: 37111645

Thanks Rob
Isn't this patch for SQL on whole itself
SQL2000-KB815495-8.00.0818-ENU.exe
Then why should we mention password and instance etc?


For this patch should i make the above 2 snippet changes?
http://support.microsoft.com/kb/821277

 

by: RobSampsonPosted on 2011-11-09 at 19:00:58ID: 37111740

I don't know why it has the password and instance names, but they are listed on that page as parameters to the EXE.  I'm not sure if they're required.  You could just try installing without those parameters and see what happens.

If you want to try it without those parameters, then just change snippet 1 to the code in snippet 2 in my post above, and see what it does.

Rob.

 

by: bsharathPosted on 2011-11-09 at 20:35:06ID: 37111940

What should i change here

strPatchNumber = "942763"

 

by: bsharathPosted on 2011-11-09 at 20:42:41ID: 37111949

Also Rob if this vbs works how can i run it on a list of computers remotely

 

by: RobSampsonPosted on 2011-11-09 at 21:25:32ID: 37112034

strPatchNumber = "815495"

That's the patch number.

To be able to run it on computer's remotely, you could use PSExec
psexec -accepteula -u domain\administrator -p password @computers.txt wscript //B \\server\share\InstallPatch.vbs

Rob.

 

by: bsharathPosted on 2011-11-10 at 00:34:36ID: 37112576

psexec -accepteula -u domain\administrator -p password @computers.txt wscript //B \\server\share\InstallPatch.vbs

some machines it gets hung
anyway to fix this

Also log does not capture success or failure

 

by: bsharathPosted on 2011-11-10 at 02:19:10ID: 37113047

---------------------------
SQL2000-KB815495-8.00.0818-ENU.exe - Application Error
---------------------------
The application failed to initialize properly (0xc0000022). Click on OK to terminate the application.
---------------------------
OK  
---------------------------
I get above error

Log has this

11/10/2011 3:45:10 PM: IN3434 - Installing patch \\IN3434\all\SQL2000-KB815495-8.00.0818-ENU.exe
11/10/2011 3:45:11 PM: IN3434 - Started installation
11/10/2011 3:45:12 PM: IN3434 - Installation failed

 

by: RobSampsonPosted on 2011-11-10 at 13:12:46ID: 37117219

Did you try running it manually from the command prompt with the different variations of switches?  Try that first, and let me know what works.

Rob.

 

by: bsharathPosted on 2011-11-10 at 19:56:28ID: 37118529

I ran this


C:\>msiexec /i "\\phos\all\SQL2000-KB815495-8.00.0818-ENU.exe" /quiet /no
restart /li+ "\\phos\all\YourLogFile.txt"

Log gets create and nothing more happens

 

by: RobSampsonPosted on 2011-11-10 at 20:12:20ID: 37118562

It's not an MSI, so that won't work.

Try just this:
"\\phos\all\SQL2000-KB815495-8.00.0818-ENU.exe" /s /a /q

 

by: bsharathPosted on 2011-11-10 at 20:16:55ID: 37118574

 

by: bsharathPosted on 2011-11-10 at 20:19:39ID: 37118579

Rob then whats the way for this exe
found something here
http://www.appdeploy.com/messageboards/printable.asp?m=3842

should we convert exe to msi and try or are there any other switches i can use

 

by: RobSampsonPosted on 2011-11-10 at 20:22:23ID: 37118585

For the EXE for the patch you want, the documentation says the switches available are /s /a /q

So this should work:
"\\phos\all\SQL2000-KB815495-8.00.0818-ENU.exe" /s /a /q

Rob.

 

by: bsharathPosted on 2011-11-10 at 20:32:11ID: 37118609

I get this popup Rob


Windows ® Installer. V 3.01.4000.3959

msiexec /Option <Required Parameter> [Optional Parameter]

Install Options
      </package | /i> <Product.msi>
            Installs or configures a product
      /a <Product.msi>
            Administrative install - Installs a product on the network
      /j<u|m> <Product.msi> [/t <Transform List>] [/g <Language ID>]
            Advertises a product - m to all users, u to current user
      </uninstall | /x> <Product.msi | ProductCode>
            Uninstalls the product
Display Options
      /quiet
            Quiet mode, no user interaction
      /passive
            Unattended mode - progress bar only
      /q[n|b|r|f]
            Sets user interface level
            n - No UI
            b - Basic UI
            r - Reduced UI
            f - Full UI (default)
      /help
            Help information
Restart Options
      /norestart
            Do not restart after the installation is complete
      /promptrestart
            Prompts the user for restart if necessary
      /forcerestart
            Always restart the computer after installation
Logging Options
      /l[i|w|e|a|r|u|c|m|o|p|v|x|+|!|*] <LogFile>
            i - Status messages
            w - Nonfatal warnings
            e - All error messages
            a - Start up of actions
            r - Action-specific records
            u - User requests
            c - Initial UI parameters
            m - Out-of-memory or fatal exit information
            o - Out-of-disk-space messages
            p - Terminal properties
            v - Verbose output
            x - Extra debugging information
            + - Append to existing log file
            ! - Flush each line to the log
            * - Log all information, except for v and x options
      /log <LogFile>
            Equivalent of /l* <LogFile>
Update Options
      /update <Update1.msp>[;Update2.msp]
            Applies update(s)
      /uninstall <PatchCodeGuid>[;Update2.msp] /package <Product.msi | ProductCode>
            Remove update(s) for a product
Repair Options
      /f[p|e|c|m|s|o|d|a|u|v] <Product.msi | ProductCode>
            Repairs a product
            p - only if file is missing
            o - if file is missing or an older version is installed (default)
            e - if file is missing or an equal or older version is installed
            d - if file is missing or a different version is installed
            c - if file is missing or checksum does not match the calculated value
            a - forces all files to be reinstalled
            u - all required user-specific registry entries (default)
            m - all required computer-specific registry entries (default)
            s - all existing shortcuts (default)
            v - runs from source and recaches local package
Setting Public Properties
      [PROPERTY=PropertyValue]

Consult the Windows ® Installer SDK for additional documentation on the
command line syntax.

Copyright © Microsoft Corporation. All rights reserved.
Portions of this software are based in part on the work of the Independent JPEG Group.

 

by: bsharathPosted on 2011-11-10 at 20:32:49ID: 37118611

I used

C:\>msiexec /i "\\phos\all\SQL2000-KB815495-8.00.0818-ENU.exe" /s /a /q " \\phos\all\YourLogFile.txt"

 

by: RobSampsonPosted on 2011-11-10 at 20:34:53ID: 37118616

It's not an MSI.  You can't use msiexec.

Just type
"\\phos\all\SQL2000-KB815495-8.00.0818-ENU.exe" /s /a /q

at a command prompt and see what it does.

 

by: bsharathPosted on 2011-11-10 at 20:56:20ID: 37118667

Yes Rob this works

Now how can i install this on many systems

 

by: RobSampsonPosted on 2011-11-10 at 21:36:27ID: 37118748

So if that works, it should work in the script just by changing the first snippet to the second snippet in comment ID 37110890.

Then, we could use code like that here:
http://www.experts-exchange.com/Programming/Languages/Q_26280035.html

which splits your large computers.txt file into batches for the script to run.  That script probably won't work as it is, but I can help rewrite that next week.

Rob.

 

by: bsharathPosted on 2011-11-14 at 18:57:42ID: 37135831

Hi Rob,

In the script now i am trying to run
MicrosoftFixit50773.msi
When run nothing happens. I did the changes as mentioned before for exe. Now to use it for Msi should i change them ?


Also any help with the script to run Exe's on many machines

 

by: RobSampsonPosted on 2011-11-14 at 20:20:08ID: 37135997

This one should work for MSI's as it is.  Check the individual log files.

I think for further modifications, we should start a new question.

Rob.

 

by: bsharathPosted on 2011-11-14 at 20:52:37ID: 37136068

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...