PDA

View Full Version : Organizzare aggiornamenti automatici notturni


Il Secchione
23-07-2015, 12:21
Ciao a tutti!
Ho un HP DC7700 e vorrei realizzare quanto segue:

- Programmare accensione automatica del pc (probabilmente da BIOS) alle 2.30 del mattino
- Con le impostazioni di Windows Update, far scaricare ed installare automaticamente gli aggiornamenti alle 3.00 circa
- Far spegnere il PC a cose fatte alle 3.30 circa (consentendo cosi' eventuali riavvii dovuti agli aggiornamenti)

Ho googlato un po' ma senza successo: il problema fondamentale e' automatizzare, magari, lo spegnimento al termine degli aggiornamenti disponibili...

Cosa potete consigliarmi? Si puo' creare un'attivita' che, al termine dei processi di aggiornamento di Windows Update, spegne il pc?

Grazie e buona giornata.
Andrea

x_Master_x
24-07-2015, 09:20
Puoi usare un VBS che faccia tutto ( riguardo ai punti 2 e 3 )
Ne esistono molti online da cui partire, ad esempio:

' Written in 2007 by Harry Johnston, University of Waikato, New Zealand.
' This code has been placed in the public domain. It may be freely
' used, modified, and distributed. However it is provided with no
' warranty, either express or implied.
'
' Exit Codes:
' 0 = scripting failure
' 1 = error obtaining or installing updates
' 2 = installation successful, no further updates to install
' 3 = reboot needed; rerun script after reboot
'
' Note that exit code 0 has to indicate failure because that is what
' is returned if a scripting error is raised.
'

Set updateSession = CreateObject("Microsoft.Update.Session")

Set updateSearcher = updateSession.CreateUpdateSearcher()
Set updateDownloader = updateSession.CreateUpdateDownloader()
Set updateInstaller = updateSession.CreateUpdateInstaller()

Do

WScript.Echo
WScript.Echo "Searching for approved updates ..."
WScript.Echo

Set updateSearch = updateSearcher.Search("IsInstalled=0")

If updateSearch.ResultCode <> 2 Then

WScript.Echo "Search failed with result code", updateSearch.ResultCode
WScript.Quit 1

End If

If updateSearch.Updates.Count = 0 Then

WScript.Echo "There are no updates to install."
WScript.Quit 2

End If

Set updateList = updateSearch.Updates

For I = 0 to updateSearch.Updates.Count - 1

Set update = updateList.Item(I)

WScript.Echo "Update found:", update.Title

Next

WScript.Echo

updateDownloader.Updates = updateList
updateDownloader.Priority = 3

Set downloadResult = updateDownloader.Download()

If downloadResult.ResultCode <> 2 Then

WScript.Echo "Download failed with result code", downloadResult.ResultCode
WScript.Echo

WScript.Quit 1

End If

WScript.Echo "Download complete. Installing updates ..."
WScript.Echo

updateInstaller.Updates = updateList

Set installationResult = updateInstaller.Install()

If installationResult.ResultCode <> 2 Then

WScript.Echo "Installation failed with result code", installationResult.ResultCode

For I = 0 to updateList.Count - 1

Set updateInstallationResult = installationResult.GetUpdateResult(I)
WScript.Echo "Result for " & updateList.Item(I).Title & " is " & installationResult.GetUpdateResult(I).ResultCode

Next

WScript.Quit 1

End If

If installationResult.RebootRequired Then

WScript.Echo "The system must be rebooted to complete installation."

WScript.Quit 3

End If

WScript.Echo "Installation complete."

Loop


Una pagina MSDN sull'argomento:
Searching, Downloading, and Installing Updates (https://msdn.microsoft.com/en-us/library/windows/desktop/aa387102(v=vs.85).aspx)

Puoi modificarlo nei punti degli "Exit Codes" per impostare lo spegnimento/riavvio del PC con la linea di comando SHUTDOWN, il resto lo devi fare tramite l'Utilità di pianificazione con Task eseguita come utente SYSTEM.

Il Secchione
24-07-2015, 09:26
Quindi questo script lo devo inserire in una attività??? Confesso di essere digiuno della materia e dovrei aggiornarmi un po' ahah

Grazie comunque in anticipo

Inviato dal mio SM-N910F utilizzando Tapatalk

x_Master_x
25-07-2015, 09:49
Se sei a digiuno è il caso di informarsi meglio, devi essere in grado di gestire il tutto da solo altrimenti alla prima difficoltà che incontri non sarai in grado di procedere. Comunque sì lo script va inserito in una attività ma quello script deve essere modificato per far sì che autonomamente il PC venga riavviato/spento a seconda delle necessità.