2010-07-05 61 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