-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck_win_updates.wsf
executable file
·39 lines (33 loc) · 1.09 KB
/
check_win_updates.wsf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<job>
<script language="VBScript">
' Reboot required?
reboot = " not checking for reboot"
Set objSysInfo = CreateObject("Microsoft.Update.SystemInfo")
If objSysInfo.RebootRequired Then
reboot = " Reboot required!"
status = 1
Else
reboot = " No Reboot required."
status = 0
End If
' updates available?
Set updateSession = CreateObject("Microsoft.Update.Session")
updateSession.ClientApplicationID = "binfalse.de check windows updates"
Set updateSearcher = updateSession.CreateUpdateSearcher()
Set searchResult = _
updateSearcher.Search("IsAssigned=1 and IsHidden=0 and IsInstalled=0")
If searchResult.Updates.Count = 0 Then
WScript.Echo "No updates detected." & reboot
Else
status = 2
info = "Updates: "
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
' WScript.Echo I + 1 & "> " & update.Title
info = info & update.Title & "; "
Next
WScript.Echo searchResult.Updates.Count & " updates detected!" & reboot & "|" & info
End If
Wscript.Quit(status)
</script>
</job>