diff --git a/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Disable Microsoft Copilot (default).ps1 b/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Disable Microsoft Copilot (default).ps1 new file mode 100644 index 0000000000..e8990ea58e --- /dev/null +++ b/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Disable Microsoft Copilot (default).ps1 @@ -0,0 +1,24 @@ +#Requires -RunAsAdministrator + +param ( + [switch]$NonInteractive +) + +$windir = [Environment]::GetFolderPath('Windows') +& "$windir\AtlasModules\initPowerShell.ps1" + +# Remove PWA/app version +Get-AppxPackage -AllUsers Microsoft.Copilot* | Remove-AppxPackage -AllUsers + +# Kill Explorer to ensure Registry changes apply +$exp = Stop-Explorer + +# Registry changes +Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowCopilotButton" -Value 0 -Force -EA 0 +New-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\WindowsCopilot" -Name "TurnOffWindowsCopilot" -PropertyType DWord -Value 1 -Force + +# Start Explorer again +Restart-Explorer -ExplorerStarted $exp + +Write-Host "Finished, changes are applied." -ForegroundColor Green +Read-Pause \ No newline at end of file diff --git a/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Enable Microsoft Copilot.ps1 b/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Enable Microsoft Copilot.ps1 new file mode 100644 index 0000000000..2bd6151da1 --- /dev/null +++ b/src/playbook/Executables/AtlasDesktop/3. General Configuration/Microsoft Copilot/Enable Microsoft Copilot.ps1 @@ -0,0 +1,44 @@ +#Requires -RunAsAdministrator + +param ( + [switch]$NonInteractive +) + +$windir = [Environment]::GetFolderPath('Windows') +& "$windir\AtlasModules\initPowerShell.ps1" + +# Check if Edge is installed +$edgeArgs = @{ + OnlyEdge = $true + NonInteractive = $NonInteractive +} +Invoke-EdgeTest @edgeArgs + +# Decide if Copilot is available +# If not, it could be 24H2 (which replaces it with an app) +try { + $copilotAvailable = Get-ItemPropertyValue -Path "HKCU:\Software\Microsoft\Windows\Shell\Copilot" -Name "IsCopilotAvailable" -EA 0 +} catch { + $appText = "You can find the Copilot app in your Start Menu." +} + +if ($copilotAvailable -eq 0) { + Write-Warning "Copilot on the taskbar isn't available, the app will be installed instead." + & "$winver\AtlasModules\Scripts\wingetCheck.cmd" /nodashes $(if ($NonInteractive) { '/silent' }) + if ($LASTEXITCODE -ne 0) { exit 1 } + + Write-Output "Installing Copilot..." + winget install -e --id 9NHT9RB2F4HD --uninstall-previous -h --accept-source-agreements --accept-package-agreements --force --disable-interactivity | Out-Null +} else { + # Show in taskbar + Set-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" -Name "ShowCopilotButton" -Value 1 -EA 0 +} + +# Delete policy +Remove-ItemProperty -Path "HKCU:\Software\Policies\Microsoft\Windows\WindowsCopilot" -Name "TurnOffWindowsCopilot" -Force -EA 0 + +# Restart Explorer to apply changes +Restart-Explorer + +Write-Host "Finished, changes are applied. $appText" -ForegroundColor Green +Read-Pause \ No newline at end of file diff --git a/src/playbook/Executables/AtlasModules/Other/atlas-script.ico b/src/playbook/Executables/AtlasModules/Other/atlas-script.ico new file mode 100644 index 0000000000..ce240d6805 Binary files /dev/null and b/src/playbook/Executables/AtlasModules/Other/atlas-script.ico differ diff --git a/src/playbook/Executables/AtlasModules/Scripts/Modules/Edge/Edge.psm1 b/src/playbook/Executables/AtlasModules/Scripts/Modules/Edge/Edge.psm1 new file mode 100644 index 0000000000..fbefd047df --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Modules/Edge/Edge.psm1 @@ -0,0 +1,60 @@ +$windir = [Environment]::GetFolderPath('Windows') +$removeEdge = "$windir\AtlasModules\Scripts\ScriptWrappers\RemoveEdge.ps1" +$edgePath = "$([Environment]::GetFolderPath('ProgramFilesx86'))\Microsoft\Edge\Application\msedge.exe" + +function Invoke-EdgeTest { + param ( + [switch]$OnlyEdge, + [switch]$OnlyWebView, + [switch]$NonInteractive + ) + + $dashes = "-" * 101 + Write-Output "`n$dashes" + + function Install { + try { + $edgeArgs = @{ + NonInteractive = $true + InstallWebView = $true + } + if (!$edgeInstalled) { $edgeArgs.Add('InstallEdge', $true); Write-Output "" } + + & $removeEdge @edgeArgs + } catch { + Write-Host "`nSomething went wrong trying to update or install Edge: $_" -ForegroundColor Red + if (!$NonInteractive) { Read-Pause } + exit 1 + } + } + + try { + # Install only WebView if Edge is already installed, or if OnlyWebView set + if ($OnlyWebView -or (Test-Path $edgePath)) { + if ($OnlyEdge) { + Write-Output "Edge is already installed, which is good as it's required for this script. :)" + return + } + + $edgeInstalled = $true + Write-Output "Updating Edge WebView 2..." + Install + return + } else { + $edgeInstalled = $false + } + + Write-Output "Microsoft Edge is required to use this script." + choice /c:yn /n /m "Would you like to install Edge? [Y/N] " + if ($LASTEXITCODE -eq 2) { + Read-Pause -NewLine + exit + } + Install + return + } finally { + Write-Output "$dashes`n" + } +} + +Export-ModuleMember -Function Invoke-EdgeTest \ No newline at end of file diff --git a/src/playbook/Executables/AtlasModules/Scripts/Modules/Explorer/Explorer.psm1 b/src/playbook/Executables/AtlasModules/Scripts/Modules/Explorer/Explorer.psm1 new file mode 100644 index 0000000000..41f0d79481 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Modules/Explorer/Explorer.psm1 @@ -0,0 +1,30 @@ +function Get-ExplorerStatus { + if (Get-Process -Name explorer -EA 0) { + $true + } else { + $false + } +} + +function Restart-Explorer { + param ( + [switch]$ExplorerStarted = !(Get-ExplorerStatus) + ) + if ($ExplorerStarted) { return } + Stop-Process -Name explorer -Force -EA 0 +} + + +function Start-Explorer { + Start-Process explorer +} + +function Stop-Explorer { + # If Explorer isn't started, return false + if (!(Get-ExplorerStatus)) { return $false } + + taskkill /f /im explorer.exe *>$null + return $true +} + +Export-ModuleMember -Function Get-ExplorerStatus, Restart-Explorer, Start-Explorer, Stop-Explorer \ No newline at end of file diff --git a/src/playbook/Executables/AtlasModules/Scripts/Modules/WinGet/WinGet.psm1 b/src/playbook/Executables/AtlasModules/Scripts/Modules/WinGet/WinGet.psm1 new file mode 100644 index 0000000000..b980967abe --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/Modules/WinGet/WinGet.psm1 @@ -0,0 +1,62 @@ +function Invoke-WinGetCheck { + param ( + [switch]$NonInteractive, + [switch]$NoDashes, + [switch]$NonFatal + ) + + $dashes = '-' * 101 + if (!$Silent -and !$NoDashes) { + Write-Host $dashes + } + + # Check internet by pinging Microsoft + if (!(Test-Connection -ComputerName "www.microsoft.com" -Count 1 -Quiet)) { + if ($NonFatal) { return $false } + + Write-Error "You must have an internet connection to continue." + if (!$NonInteractive) { Read-Pause } + + exit 2 + } + + Write-Host "Checking for WinGet..." + + function WingetError($uri, $action) { + Write-Host @" +You need the latest version of WinGet to use this script. +WinGet is included with 'App Installer' on the Microsoft Store, it's also on GitHub. +"@ -ForegroundColor Yellow + + choice /c:yn /n /m "Would you like to open the Microsoft Store to $action it? [Y/N] " + if ($LASTEXITCODE -eq 1) { + Start-Process $uri + } + exit 3 + } + + # Check if WinGet is installed + if (!(Get-Command "winget" -EA 0)) { + if ($NonFatal) { return $false } + + # Open Microsoft Store for App Installer if not installed + WingetError "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" "install" + } + + # Check WinGet functionality by searching for VSCode + winget search "Microsoft Visual Studio Code" --accept-source-agreements --disable-interactivity --ignore-warnings *>$null + if (!$?) { + if ($Silent) { exit 1 } + + # Open Microsoft Store to update apps if search fails + WingetError "ms-windows-store://downloadsandupdates" "update" + } + + if (!$NoDashes) { + Write-Host "$dashes`n" + } + + return $true +} + +Export-ModuleMember -Function Invoke-WinGetCheck \ No newline at end of file diff --git a/src/playbook/Executables/AtlasModules/Scripts/WingetCheck.ps1 b/src/playbook/Executables/AtlasModules/Scripts/WingetCheck.ps1 new file mode 100644 index 0000000000..3ae0bfe6f9 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/WingetCheck.ps1 @@ -0,0 +1,58 @@ +param ( + [switch]$NonInteractive, + [switch]$NoDashes, + [switch]$NonFatal +) + +$dashes = '-' * 101 +if (!$Silent -and !$NoDashes) { + Write-Output $dashes +} + +# Check internet by pinging Microsoft +if (!(Test-Connection -ComputerName "www.microsoft.com" -Count 1 -Quiet)) { + if ($NonFatal) { return $false } + + Write-Error "You must have an internet connection to continue." + if (!$NonInteractive) { Read-Pause } + + exit 2 +} + +Write-Output "Checking for WinGet..." + +function WingetError($uri, $action) { + Write-Host @" +You need the latest version of WinGet to use this script. +WinGet is included with 'App Installer' on the Microsoft Store. +"@ -ForegroundColor Yellow + + choice /c:yn /n /m "Would you like to open the Microsoft Store to $action it? [Y/N] " + if ($LASTEXITCODE -eq 1) { + Start-Process $uri + } + exit 3 +} + +# Check if WinGet is installed +if (!(Get-Command "winget" -EA 0)) { + if ($NonFatal) { return $false } + + # Open Microsoft Store for App Installer if not installed + WingetError "ms-windows-store://pdp/?ProductId=9NBLGGH4NNS1" "install" +} + +# Check WinGet functionality by searching for VSCode +winget search "Microsoft Visual Studio Code" --accept-source-agreements --disable-interactivity --ignore-warnings *>$null +if (!$?) { + if ($Silent) { exit 1 } + + # Open Microsoft Store to update apps if search fails + WingetError "ms-windows-store://downloadsandupdates" "update" +} + +if (!$NoDashes) { + Write-Output "$dashes`n" +} + +return $true \ No newline at end of file