Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

install hotfix on remote computers 1

Status
Not open for further replies.
Sep 12, 2002
282
0
0
SG
hi,
how can i install a hotfix to 100 computers using vbs ?
thanks
 
Philippe:

to make things easy, just to get the patch installed on your workstation, do the following:
[ol][li]Copy the hotfix to the workstation to be patched (ie. C:\temp)[/li]
[li]Open command prompt[/li]
[li]Type
Code:
psexec \\poste01-cdgi "C:\temp\q315000.exe -u -z -q"
[/li][/ol]
The path
Code:
"C:\temp\q315000.exe -u -z -q"
should be the location on the remote machine. As long as you have privs on the remote machine this will install silently on the remote workstation. You will receive an error if you don't. Like I said I will look at making this more generic, but I won't have time to look at it tonight :-(

------------------------------------------------------------------------------
nobody knows everything about IT, so make a point to help your fellow members

-= j@ckle =-
 
Thanks for your time.

I'v been looking out for a solution that would work on all NT platforms. I found something and I modified it with my brother. I'm waiting for the guy who first maid it to give me permission to send it but as soon as I can I'll post it here. The script detect the OS version and apply the right patch. The problem right now is that I can only patch one system at the time. So we are working on it so we can feed the script a list of IP adress.

I'll keep you updated.
 
i use this as a vbs file works like a champ:
Const HKEY_CLASSES_ROOT = &H80000000
Const HKEY_CURRENT_USER = &H80000001
Const HKEY_LOCAL_MACHINE = &H80000002
Const HKEY_USERS = &H80000003
Const HKEY_CURRENT_CONFIG = &H80000005

On Error Resume Next
'===================
'| Create IE Object
'===================

Set objCDO = wscript.CreateObject("CDO.Message")
Set objExplorer = WScript.CreateObject("InternetExplorer.Application", "IE_")
objExplorer.Navigate ""
objExplorer.Visible = 1
objExplorer.ToolBar = 0
objExplorer.StatusBar = 0
objExplorer.Width=600
objExplorer.Height = 600
objExplorer.Left = 0
objExplorer.Top = 0
wscript.sleep 1000
While objExplorer.busy: Wend

Call Updatestatus(now())
Call pse()
Function pse()
Do While objExplorer.Document.Body.All.scan.value = "Scan"
wscript.sleep 1000
Loop
Call loader()
End Function


Function loader()
If Len(objExplorer.Document.Body.All.IPAddress.value) > 1 Then
sComputer = objExplorer.Document.Body.All.IPAddress.value
Else
sComputer = inputbox("Enter IP To scan")
End If
Call Updatestatus(vbCrlf & "Scanning: " & sComputer)
Call checkos(sComputer)
End Function

Function Checkos(ipaddress)

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}\\" & IPAddress & "\root\cimv2")

Set colSystem=objWMIService.ExecQuery ("Select * from Win32_operatingsystem")
For Each objSystem In colSystem
scaption = objSystem.caption
Next
Call Updatestatus("Found " & scaption)
Call Checkpatch(ipaddress, scaption)
End Function

Function Checkpatch(sComputer, os)
sMethod = "EnumKey"
hTree = HKEY_LOCAL_MACHINE
sKey = "SOFTWARE\Microsoft\Windows NT\CurrentVersion\hotfix"
srckey = "KB824146" 'Inputbox("Enter Hot Fix ID")
Call Updatestatus("Checking for patch " & srckey)
Dim hFixes
Dim objWMIService, objSystem
Dim ColSystem

Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate,AuthenticationLevel=pktprivacy}//" & sComputer & "/root/default:StdRegProv")

Set oMethod = oRegistry.Methods_(sMethod)
Set oInParam = oMethod.inParameters.SpawnInstance_()

oInParam.hDefKey = hTree
oInParam.sSubKeyName = sKey

Set oOutParam = oRegistry.ExecMethod_(sMethod, oInParam)

For i=0 To UBound(oOutParam.Properties_("sNames"))
If instr(oOutParam.Properties_("sNames")(i), srckey) Then
fnd = True
i=UBound(oOutParam.Properties_("sNames"))
End If
Next
If FND = False Then
Call updatestatus("Applying patch")
sMethod = "SetStringValue"
hTree = HKEY_LOCAL_MACHINE
sKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce"
sValueName = "MS03039"
Select Case lcase(os)
Case lcase("Microsoft Windows 2000 Professional")
sValue = "\\{servername}\pccommon\patches\MS03-039\Windows2000-KB824146-x86-ENU.exe -q"
Case lcase("Microsoft Windows XP Professional")
sValue = "\\{servername}\pccommon\patches\MS03-039\WindowsXP-KB824146-x86-ENU.exe -q"
Case lcase("Microsoft Windows NT Workstation")
sValue = "\\{servername}\pccommon\patches\MS03-039\WindowsNT4Workstation-KB824146-x86-ENU.EXE -q"
Case Else
sValue = inputbox("Enter patch to run:")
End Select

Call updatestatus("Applying patch " & sValueName)
Call updatestatus("Installing From " & sValue)

Set oMethod = oRegistry.Methods_(sMethod)
Set oInParam = oMethod.inParameters.SpawnInstance_()
oInParam.hDefKey = hTree
oInParam.sSubKeyName = sKey
oInParam.sValueName = sValueName
oInParam.sValue = sValue

Set oOutParam = oRegistry.ExecMethod_(sMethod, oInParam)
Call updatestatus("Sending Notification to " & sComputer)
Call ExternalApp("net send " & scomputer & " Information Systems ask that you reboot your pc to apply new security patch for windows. This patch was just applied to your system. Questions please call ", 1 ,1)
Call updatestatus("Registery key edited.")
Else
Call updatestatus("update not required")
End If
Call closer()
End Function

Function closer()
checkclose = msgbox("Do you wish to scan another system?", vbYesno)
If checkclose = vbyes Then
objExplorer.Document.Body.All.scan.value = "Scan"
Call pse()
Exit function
Else
wscript.sleep 3000
If objExplorer.Document.Body.All.wclose.checked Then
objExplorer.quit
End If
End If

End Function

Function Updatestatus(comments)
objExplorer.Document.Body.All.webpage.Value = comments & vbCrlf & objExplorer.Document.Body.All.webpage.Value
End Function

Function ExternalApp(appname, var1, var2)
Set WshShell = Wscript.CreateObject("Wscript.Shell")
WshShell.Run appname, var1, var2
End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top