How to fully update Windows XP from command-line?
Recently I’ve needed to upgrade my PC from a command line.
After a lot of searching, including Microsoft tech-support where I was told that it’s not possible, I’ve managed to do it using Windows Scripting. Here is a VBS script that does the thing and reboots the machine afterwards:
wshShell.run “net stop wuauserv”,0,True
wshShell.run “net start wuauserv”,0,True
Set updateSession = CreateObject(“Microsoft.Update.Session”)
Set updateSearcher = updateSession.CreateupdateSearcher()
Set searchResult = updateSearcher.Search(“IsInstalled=0 and Type=’Software’”)
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
Next
If searchResult.Updates.Count = 0 Then
wshShell.run “shutdown -r -f -t 0″
End If
Set updatesToDownload = CreateObject(“Microsoft.Update.UpdateColl”)
For I = 0 to searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
updatesToDownload.Add(update)
Next
Set downloader = updateSession.CreateUpdateDownloader()
downloader.Updates = updatesToDownload
downloader.Download()
For I = 0 To searchResult.Updates.Count-1
Set update = searchResult.Updates.Item(I)
Next
Set updatesToInstall = CreateObject(“Microsoft.Update.UpdateColl”)
For I = 0 To searchResult.Updates.Count-1
set update = searchResult.Updates.Item(I)
If update.IsDownloaded = true Then
updatesToInstall.Add(update)
End If
Next
Set installer = updateSession.CreateUpdateInstaller()
installer.Updates = updatesToInstall
installer.Install()
wshShell.run “shutdown -r -f -t 0″
Just paste it into script.vbs file and run.
Hope helps somebody :)
I think that for this is a script in WAIK/WDS done by MS :-)
If you know a better one, then post a link please :)