ORF反垃圾邮件系统

邮件服务器-邮件系统-邮件技术论坛(BBS)

 找回密码
 会员注册
查看: 9675|回复: 5

[技巧] IMF自动更新脚本

[复制链接]
发表于 2007-1-12 13:36:20 | 显示全部楼层 |阅读模式
在微软找到的一个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

评分

参与人数 1经验积分 +10 收起 理由
钉子 + 10 很给力!

查看全部评分

发表于 2007-1-12 13:58:49 | 显示全部楼层
我顶。好东西要支持
发表于 2007-1-12 14:06:17 | 显示全部楼层
IMF可以通过Microsoft Update 和“自动更新”技术进行自动更新。可以看下面这个kb:

http://www.5dmail.net/html/2006-4-26/200642602505.htm

如何启用更新
在 Exchange 系统管理器中启用智能邮件筛选器后,为了启用智能邮件筛选器更新,必须创建 ContentFilterState 注册表项。为此,请按照下列步骤操作: 1. 单击“开始”,单击“运行”,键入 regedit,然后单击“确定”。
2. 展开以下注册表子项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Exchange
3. 在左窗格中,单击“Exchange”。然后,右键单击右窗格,指向“新建”,然后单击“DWORD 值”。
4. 键入 ContentFilterState,然后按 Enter 以命名新的注册表项。
5. 右键单击“ContentFilterState”,然后单击“修改”。
6. 在“数值数据”框中,键入 1,然后单击“确定”。
7. 退出注册表编辑器。
8. 在“服务”管理单元中,重新启动“简单邮件传输协议(SMTP)”服务。
发表于 2007-3-21 10:27:14 | 显示全部楼层
请问 做完 注册表的修改以后。。IMF就能自动更新了?不用再作任何操作?怎么能确定 IMF已经更新到最新版本呢?
发表于 2007-3-22 11:31:19 | 显示全部楼层
现在知道怎么更新了 要用   Microsoft Update 就可以更新IMF数据了,Windows Update是不能更新的。
发表于 2012-1-11 08:05:03 | 显示全部楼层
完全没有明白这个更新机制啊,不过还是谢谢有两种方式可以试试了
您需要登录后才可以回帖 登录 | 会员注册

本版积分规则

小黑屋|手机版|Archiver|邮件技术资讯网

GMT+8, 2024-4-18 10:57

Powered by Discuz! X3.2

© 2001-2016 Comsenz Inc.

本论坛为非盈利中立机构,所有言论属发表者个人意见,不代表本论坛立场。内容所涉及版权和法律相关事宜请参考各自所有者的条款。
如认定侵犯了您权利,请联系我们。本论坛原创内容请联系后再行转载并务必保留我站信息。此声明修改不另行通知,保留最终解释权。
*本论坛会员专属QQ群:邮件技术资讯网会员QQ群
*本论坛会员备用QQ群:邮件技术资讯网备用群

快速回复 返回顶部 返回列表