-
-
Notifications
You must be signed in to change notification settings - Fork 555
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update drivers through windows update file
https://github.com/orgs/Atlas-OS/projects/7?pane=issue&itemId=70790980 feat: update drivers through windows update file https://github.com/orgs/Atlas-OS/projects/7?pane=issue&itemId=70790980
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
src/playbook/Executables/AtlasDesktop/2. Drivers/Run Update Drivers.cmd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
@echo off | ||
set "script=%windir%\AtlasModules\Scripts\ScriptWrappers\UpdateDrivers.ps1" | ||
|
||
if not exist "%script%" ( | ||
echo Script not found: "%script%" | ||
pause | ||
exit /b 1 | ||
) | ||
|
||
whoami /user | find /i "S-1-5-18" > nul 2>&1 || ( | ||
call RunAsTI.cmd "%~f0" %* | ||
exit /b | ||
) | ||
|
||
@REM The "echo Y" is to bypass the NuGet installation user prompt. | ||
@REM If there's a better way, feel free to PR. | ||
echo Y | powershell -ExecutionPolicy Bypass -NoProfile -File "%script%" | ||
|
||
pause | ||
exit /b 0 |
53 changes: 53 additions & 0 deletions
53
src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/UpdateDrivers.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[CmdletBinding()] | ||
param ( | ||
[switch]$RestartAfterUpdate | ||
) | ||
|
||
function Install-PSWindowsUpdateModule { | ||
# Make sure that PowerShellGet is updated just in case | ||
if (-not (Get-Module -ListAvailable -Name PowerShellGet)) { | ||
Install-Module -Name PowerShellGet -Force -AllowClobber -Confirm:$false -Scope AllUsers | ||
} | ||
|
||
# Making it trusted now will avoid further user prompts in the future | ||
if ((Get-PSRepository -Name PSGallery).InstallationPolicy -ne "Trusted") { | ||
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted | ||
} | ||
|
||
# Install PSWindowsUpdate | ||
if (-not (Get-Module -ListAvailable -Name PSWindowsUpdate)) { | ||
Install-Module -Name PSWindowsUpdate -Force -Scope CurrentUser -Confirm:$false | ||
} | ||
} | ||
|
||
function Enable-MicrosoftUpdate { | ||
Write-Host "Enabling Microsoft Update for driver updates..." | ||
Add-WUServiceManager -ServiceID "7971f918-a847-4430-9279-4a52d1efe18d" -AddServiceFlag 7 -Confirm:$false | Out-Null | ||
} | ||
|
||
function Update-Drivers { | ||
Write-Host "Checking for driver updates..." | ||
$Updates = Get-WUList -MicrosoftUpdate -Category "Drivers" | ||
|
||
if ($Updates.Count -gt 0) { | ||
Write-Host "Installing available driver updates..." | ||
$Updates | Format-Table ComputerName, Status, KB, Size, Title -AutoSize | ||
Get-WUInstall -MicrosoftUpdate -Category "Drivers" -AcceptAll -IgnoreReboot -Confirm:$false | Out-Null | ||
Write-Host "Driver updates installed successfully!" | ||
|
||
# Restart if needed | ||
if ($RestartAfterUpdate) { | ||
Write-Host "Restarting the system in 10 seconds..." | ||
Start-Sleep -Seconds 10 | ||
Restart-Computer -Force | ||
} | ||
} else { | ||
Write-Host "No driver updates found." | ||
} | ||
} | ||
|
||
Install-PSWindowsUpdateModule | ||
Enable-MicrosoftUpdate | ||
Update-Drivers | ||
|
||
Write-Host "Driver update process completed." |