2010-07-05 60 views
1

有人有一个脚本/或可以帮助我检查,是否有可用的服务器的Windows更新?Windows更新检查与vbscript

因此,当黄色更新图标位于任务栏中时,我将收到一封邮件。

我的想法是:发送邮件,如果wuauclt.exe在任务栏中超过10分钟。

但我不知道这样做。

我发现只有这个:

Dim strComputer, strProcess 
Do 
    strProcess = inputbox("Please enter the name of the process (for instance: explorer.exe)", "Input") 
Loop until strProcess <> "" 
Do 
    strComputer = inputbox("Please enter the computer name", "Input") 
Loop until strComputer <> "" 
If(IsProcessRunning(strComputer, strProcess) = True) Then 
    WScript.Echo "Process " & strProcess & " is running on computer " & strComputer 
Else 
    WScript.Echo "Process " & strProcess & " is NOT running on computer " & strComputer 
End If 

感谢您的帮助。

回答

5

如何像这样

'Microsoft magic 
    Set updateSession = CreateObject("Microsoft.Update.Session") 
    Set updateSearcher = updateSession.CreateupdateSearcher()   
    Set searchResult = updateSearcher.Search("IsInstalled=0 and Type='Software'") 
'End Microsoft magic 

If searchResult.Updates.Count <> 0 Then 'If updates were found 
    'This is where you add your code to send an E-Mail. 
    'Send E-mail including a list of updates needed. 

    'This is how you can list the title of each update that was found. 
    'You could include the list in the body of your E-Mail. 
    For i = 0 To searchResult.Updates.Count - 1 
     Set update = searchResult.Updates.Item(i) 
     WScript.Echo update.Title 
    Next 
End If 
+0

你能解释一下你的代码吗? – Sebastian 2010-07-07 08:45:32

+0

@matthias:我在代码中添加了一些注释。 – Tester101 2010-07-08 18:23:04

+0

谢谢,这是一个很好的代码... – Sebastian 2010-07-12 12:16:37

0

wuauclt很可能会运行超过10分钟,而不一定要通知用户有未决的更新。

我知道这是StackOverflow,这是一个编程问题,但我是一个系统管理员,我认为这属于ServerFault,并且你做错了。 WSUS(http://technet.microsoft.com/en-us/wsus/default.aspx)旨在管理Windows更新。

+0

感谢您的回答。我们使用WSUS,但是我会制作一个脚本来检查服务器列表,如果有需要修补的服务器,我会收到一封邮件。你知道我的意思? :-) – Sebastian 2010-07-06 05:34:10

+0

您可以直接从WSUS控制台获取报告和电子邮件警报,无需编码。他们不是很好配置,但很容易看到需要补丁的服务器列表,以及他们需要哪些补丁... – ewall 2010-07-06 15:29:34