在微软找到的一个IMF自动更新脚本...
把下列内部(红字部分)拷贝到记事本后,另存为后辍名为vbs的文件..然后即行即可...也可以在计划任务中让它每两个星期一次(微软一般每个月提供两次更新)..
Option Explicit
'//---------------------------------------------------------------------
'//This is a sample script, not officially supported by Microsoft.
'//---------------------------------------------------------------------
'Simple VBScript to show usage
'Forgetting to use cscript.exe could lead to annoying pop-ups when wscript.echo is called.
'Will run on any machine but only will do *stuff* on an Exchange server configured according to http://support.microsoft.com/?kbid=907747
On Error Resume Next
Dim error, i
Dim objUpdateSession, objUpdateSearcher, objSearchResult
Dim objupdateInfo, BundleUpdate
Dim objUpdatesToDownload, objUpdatesToInstall
Dim UpdateAction, bInstall, bDetect
Dim IUpdate
Dim downloader, installer
Dim installationResult
bInstall = false
if WScript.Arguments.Count = 1 Then
UpdateAction = lcase(WScript.Arguments.Item(0))
Select Case (UpdateAction)
Case ("install")
bInstall = vbTrue
Case ("detect")
bInstall = vbFalse
Case Else
Usage
End Select
else
Usage
end if
Set objUpdateSession = CreateObject("Microsoft.Update.Session")
if (err.number <> 0) then
msgEcho ("Microsoft.Update.Session is not present - have you connected to MicrosoftUpdates before?")
msgEcho ("Microsoft.Update.Session is not present - have you connected to http://update.microsoft.com/MicrosoftUpdate before?")
end if
Set objUpdatesToDownload = CreateObject("Microsoft.Update.UpdateColl")
Set objUpdatesToInstall = CreateObject("Microsoft.Update.UpdateColl")
msgEcho ( "Setting UpdateSession to Microsoft Update")
Set objUpdateSearcher = objUpdateSession.CreateupdateSearcher()
objUpdateSession.CreateupdateSearcher()
'By default, the scan will use what AU is configured to use. It could be WSUS or MU/WU.
'If you want to force the scan to use Microsoft Update and not what AU is configured to use simply uncomment the below lines
'objUpdateSearcher.ServiceID ="7971f918-a847-4430-9279-4a52d1efe18d"
'objUpdateSearcher.ServerSelection = 3
'objUpdateSearcher.Online = true
msgEcho ("Setting SearchResult and performing search")
Set objSearchResult = objUpdateSearcher.Search("CategoryIDs contains '3cf32f7c-d8ee-43f8-a0da-8b88a6f8af1a'") 'Exchange 2003 GUID
if (err.number <> 0) then
msgEcho ("Have you set the ContentFilterState DWORD registry value?")
msgEcho ("you connected to http://update.microsoft.com/MicrosoftUpdate?")
end if
msgEcho ("Search completed")
msgEcho ("Total Updates Returned:" & objSearchResult.Updates.Count)
'//
'// List current updates and status
'//
msgEcho ( "All Exchange Updates Status:")
msgEcho ("")
msgEcho ( VBTAB & "Is Installed: ")
For i = 0 to objSearchResult.Updates.Count-1
if (objSearchResult.Updates.Item(i).isInstalled = true) then
msgEcho ( VBTAB & VBTAB & objSearchResult.Updates.Item(i).title)
end if
Next
msgEcho ( VBTAB & "Not Installed: ")
For i = 0 to objSearchResult.Updates.Count-1
if (objSearchResult.Updates.Item(i).isInstalled = false) then
msgEcho ( VBTAB & VBTAB & objSearchResult.Updates.Item(i).title)
end if
Next
'//
'// List only the IMF updates
'//
msgEcho ("")
msgEcho ("IMF Update Status:")
msgEcho ("")
msgEcho ( VBTAB & "Is Installed: ")
For i = 0 to objSearchResult.Updates.Count-1
if ( IsTitleOfUpdateIMFUpdate(objSearchResult.Updates.Item(i).title) ) then
if (objSearchResult.Updates.Item(i).isInstalled = true) then
msgEcho ( VBTAB & VBTAB & objSearchResult.Updates.Item(i).title)
end if
end if
Next
msgEcho ( VBTAB & "Not Installed: ")
For i = 0 to objSearchResult.Updates.Count-1
'This will only work for English
if ( IsTitleOfUpdateIMFUpdate(objSearchResult.Updates.Item(i).title) ) then
if (objSearchResult.Updates.Item(i).isInstalled = false) then
msgEcho ( VBTAB & VBTAB & objSearchResult.Updates.Item(i).title)
if (bInstall) then
msgEcho ( VBTAB & VBTAB & VBTAB & "Adding to the Download Queue")
objUpdatesToDownload.Add(objSearchResult.Updates.Item(i))
end if
end if
end if
Next
if Not (bInstall) then
msgEcho ("Exiting - detection only")
wscript.quit (0)
end if
if (objUpdatesToDownload.Count = 0) then
msgEcho ("No 'Updates for Intelligent Message Filter' to download")
wscript.quit (0)
end if
msgEcho ("Downloading updates...")
Set downloader = objUpdateSession.CreateUpdateDownloader()
downloader.Updates = objUpdatesToDownload
downloader.Download()
msgEcho ("Adding downloaded updates to the install list")
For i = 0 to objUpdatesToDownload.Count-1
if (objUpdatesToDownload.Item(i).IsDownloaded = true) then
objUpdatesToInstall.Add(objUpdatesToDownload.Item(i))
end if
Next
if objUpdatesToInstall.Count = 0 then
msgEcho ("No 'Updates for Intelligent Message Filter' to install - an error at this point")
wscript.quit (-1)
end if
Set installer = objUpdateSession.CreateUpdateInstaller()
msgEcho ("Installing Updates...")
installer.Updates = objUpdatesToInstall
Set installationResult = installer.Install()
if (installationResult.ResultCode <> 2) then
msgEcho ("Installation Result: Bad Error (" & installationResult.ResultCode & ")")
else
msgEcho ("Installation Result: Succeeded")
end if
msgEcho ("Reboot Required: " & installationResult.RebootRequired)
msgEcho ("Exiting with Error 0x" & Hex(Err.Number) & " (" & Err.Description & ")")
WScript.Quit(Err.Number)
Function IsTitleOfUpdateIMFUpdate(StrTitle)
IsTitleOfUpdateIMFUpdate = vbFalse
if ( StrComp (objSearchResult.Updates.Item(i).title, "Update for Intelligent Message Filter for Exchange Server 2003:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Exchange Server 2003 Intelligent Message Filter 용 핫픽스:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Mise à jour pour Intelligent Message Filter pour Exchange Server 2003:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Update für Intelligent Message Filter für Exchange Server 2003:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Exchange Server 2003 Intelligent Message Filter 用 更新プログラム(KB907747):") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Actualización para Intelligent Message Filter para Exchange Server 2003:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Aggiornamento per Intelligent Message Filter per Exchange Server 2003:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "更新 for Exchange Server 2003 Intelligent Message Filter:") > 0 ) OR _
( StrComp (objSearchResult.Updates.Item(i).title, "Exchange Server 2003 Intelligent Message Filter 的 更新:") > 0 ) then IsTitleOfUpdateIMFUpdate = vbTrue
End Function
Sub msgEcho (strEcho)
WScript.Echo(NOW() & vbTab & strEcho)
End Sub
Sub Usage()
Wscript.Echo "Invalid Arguements"
Wscript.Echo vbTab & "Usage: imfUpdateScript.vbs ActionType"
Wscript.Echo vbTab & "ActionType - 'Detect' or 'Install'"
Wscript.Quit(-1)
End Sub |