mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-28 00:54:47 -05:00
Test 2023 7 20 (#917)
* Remove Edge from Start Menu and Desktop (#898) * Update edgeremoval.bat * Fix Edge not being deleted from Desktop * Compile Winutil * fix yubikey users service * Compile Winutil * AJRouter and Kiosk Disable * Compile Winutil * TermService enable This service will hang when applying tweaks. Changing to Auto from Manual * Compile Winutil * Fix bug with Telemetry Tweak services should NOT be tweaked here * dupe tweak removal * hibernate off and delete * Compile Winutil * Cleaning Windows Update Folder * Compile Winutil * GameDVR Fix * Compile Winutil * Fixed consistency in variable names and values inside edgeremoval.bat (#902) * Compile Winutil * add spdx license * Compile Winutil * Updated Dark mode check (#904) * Compile Winutil * Update Dark Mode Check updated the theme check to use the existing function * Description update Updated Description --------- Co-authored-by: DeveloperDurp <DeveloperDurp@users.noreply.github.com> * Compile Winutil * fixes #569 * Compile Winutil * Added Bing Search toggle plus some support functions (#908) * Compile Winutil * Update winget.ps1 * Compile Winutil * Fix Winget Install * Compile Winutil * Update Install-WinUtilWinget.ps1 * Compile Winutil * Update Install-WinUtilWinget.ps1 * Compile Winutil * Update Install-WinUtilWinget.ps1 * Compile Winutil * Winget fixes * Compile Winutil --------- Co-authored-by: Antun Nitraj <antnitraj@gmail.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: DeveloperDurp <developerdurp@durp.info> Co-authored-by: DeveloperDurp <DeveloperDurp@users.noreply.github.com>
This commit is contained in:
@ -1,16 +0,0 @@
|
||||
Function Get-WinUtilDarkMode {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Meant to pull the registry keys responsible for Dark Mode and returns true or false
|
||||
|
||||
#>
|
||||
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
|
||||
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
|
||||
if($app -eq 0 -and $system -eq 0){
|
||||
return $true
|
||||
}
|
||||
else{
|
||||
return $false
|
||||
}
|
||||
}
|
32
functions/private/Get-WinUtilToggleStatus.ps1
Normal file
32
functions/private/Get-WinUtilToggleStatus.ps1
Normal file
@ -0,0 +1,32 @@
|
||||
Function Get-WinUtilToggleStatus {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Meant to pull the registry keys for a toggle switch and returns true or false
|
||||
|
||||
True should mean status is enabled
|
||||
False should mean status is disabled
|
||||
|
||||
#>
|
||||
|
||||
Param($ToggleSwitch)
|
||||
if($ToggleSwitch -eq "WPFToggleDarkMode"){
|
||||
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
|
||||
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
|
||||
if($app -eq 0 -and $system -eq 0){
|
||||
return $true
|
||||
}
|
||||
else{
|
||||
return $false
|
||||
}
|
||||
}
|
||||
if($ToggleSwitch -eq "WPFToggleBingSearch"){
|
||||
$bingsearch = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search').BingSearchEnabled
|
||||
if($bingsearch -eq 0){
|
||||
return $false
|
||||
}
|
||||
else{
|
||||
return $true
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +1,12 @@
|
||||
function Get-LatestHash {
|
||||
$shaUrl = ((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt$' }).browser_download_url
|
||||
|
||||
$shaFile = Join-Path -Path $tempFolder -ChildPath 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.txt'
|
||||
$WebClient.DownloadFile($shaUrl, $shaFile)
|
||||
|
||||
Get-Content $shaFile
|
||||
}
|
||||
|
||||
function Install-WinUtilWinget {
|
||||
|
||||
<#
|
||||
@ -28,46 +37,63 @@ function Install-WinUtilWinget {
|
||||
return
|
||||
}
|
||||
|
||||
#Gets the Windows Edition
|
||||
$OSName = if ($ComputerInfo.OSName) {
|
||||
$ComputerInfo.OSName
|
||||
}else {
|
||||
$ComputerInfo.WindowsProductName
|
||||
Write-Host "Running Alternative Installer and Direct Installing"
|
||||
$ErrorActionPreference = "Stop"
|
||||
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
|
||||
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||
|
||||
# Hide the progress bar of Invoke-WebRequest
|
||||
$oldProgressPreference = $ProgressPreference
|
||||
$ProgressPreference = 'SilentlyContinue'
|
||||
|
||||
$desktopAppInstaller = @{
|
||||
fileName = 'Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle'
|
||||
url = $(((Invoke-WebRequest $apiLatestUrl -UseBasicParsing | ConvertFrom-Json).assets | Where-Object { $_.name -match '^Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle$' }).browser_download_url)
|
||||
hash = $(Get-LatestHash)
|
||||
}
|
||||
|
||||
if (((($OSName.IndexOf("LTSC")) -ne -1) -or ($OSName.IndexOf("Server") -ne -1)) -and (($ComputerInfo.WindowsVersion) -ge "1809")) {
|
||||
|
||||
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
||||
|
||||
# Switching to winget-install from PSGallery from asheroto
|
||||
# Source: https://github.com/asheroto/winget-installer
|
||||
|
||||
#adding the code from the asheroto repo
|
||||
Set-ExecutionPolicy RemoteSigned -force
|
||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
||||
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
|
||||
Install-Script -Name winget-install -force
|
||||
winget-instal
|
||||
|
||||
|
||||
Start-Process powershell.exe -Verb RunAs -ArgumentList "-command irm https://raw.githubusercontent.com/ChrisTitusTech/winutil/$BranchToUse/winget.ps1 | iex | Out-Host" -WindowStyle Normal -ErrorAction Stop
|
||||
|
||||
if(!(Test-WinUtilPackageManager -winget)){
|
||||
break
|
||||
$vcLibsUwp = @{
|
||||
fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||
url = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||
hash = '6602159c341bafea747d0edf15669ac72df8817299fbfaa90469909e06794256'
|
||||
}
|
||||
$uiLibs = @{
|
||||
nupkg = @{
|
||||
fileName = 'microsoft.ui.xaml.2.7.0.nupkg'
|
||||
url = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
|
||||
hash = "422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591"
|
||||
}
|
||||
uwp = @{
|
||||
fileName = 'Microsoft.UI.Xaml.2.7.appx'
|
||||
}
|
||||
}
|
||||
$uiLibs.uwp.file = $PWD.Path + '\' + $uiLibs.uwp.fileName
|
||||
$uiLibs.uwp.zipPath = '*/x64/*/' + $uiLibs.uwp.fileName
|
||||
|
||||
else {
|
||||
#Installing Winget from the Microsoft Store
|
||||
Write-Host "Winget not found, installing it now."
|
||||
Start-Process "ms-appinstaller:?source=https://aka.ms/getwinget"
|
||||
$nid = (Get-Process AppInstaller).Id
|
||||
Wait-Process -Id $nid
|
||||
$dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibs.nupkg)
|
||||
|
||||
if(!(Test-WinUtilPackageManager -winget)){
|
||||
break
|
||||
}
|
||||
foreach ($dependency in $dependencies) {
|
||||
$dependency.file = $dependency.fileName
|
||||
Invoke-WebRequest $dependency.url -OutFile $dependency.file
|
||||
}
|
||||
|
||||
$uiLibs.nupkg.file = $PSScriptRoot + '\' + $uiLibs.nupkg.fileName
|
||||
Add-Type -Assembly System.IO.Compression.FileSystem
|
||||
$uiLibs.nupkg.zip = [IO.Compression.ZipFile]::OpenRead($uiLibs.nupkg.file)
|
||||
$uiLibs.nupkg.zipUwp = $uiLibs.nupkg.zip.Entries | Where-Object { $_.FullName -like $uiLibs.uwp.zipPath }
|
||||
[System.IO.Compression.ZipFileExtensions]::ExtractToFile($uiLibs.nupkg.zipUwp, $uiLibs.uwp.file, $true)
|
||||
$uiLibs.nupkg.zip.Dispose()
|
||||
|
||||
Add-AppxPackage -Path $desktopAppInstaller.file -DependencyPath $vcLibsUwp.file,$uiLibs.uwp.file
|
||||
|
||||
Remove-Item $desktopAppInstaller.file
|
||||
Remove-Item $vcLibsUwp.file
|
||||
Remove-Item $uiLibs.nupkg.file
|
||||
Remove-Item $uiLibs.uwp.file
|
||||
Write-Host "WinGet installed!" -ForegroundColor Green
|
||||
$ProgressPreference = $oldProgressPreference
|
||||
Update-EnvironmentVariables
|
||||
|
||||
Write-Host "Winget Installed"
|
||||
}
|
||||
Catch{
|
||||
|
31
functions/private/Invoke-WinUtilBingSearch.ps1
Normal file
31
functions/private/Invoke-WinUtilBingSearch.ps1
Normal file
@ -0,0 +1,31 @@
|
||||
function Invoke-WinUtilBingSearch {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Sets Bing Search on or off
|
||||
|
||||
#>
|
||||
Param($Enabled)
|
||||
Try{
|
||||
if ($Enabled -eq $false){
|
||||
Write-Host "Enabling Bing Search"
|
||||
$value = 1
|
||||
}
|
||||
else {
|
||||
Write-Host "Disabling Bing Search"
|
||||
$value = 0
|
||||
}
|
||||
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search"
|
||||
Set-ItemProperty -Path $Path -Name BingSearchEnabled -Value $value
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
}
|
||||
Catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
33
functions/private/Invoke-WinUtilDarkMode.ps1
Normal file
33
functions/private/Invoke-WinUtilDarkMode.ps1
Normal file
@ -0,0 +1,33 @@
|
||||
Function Invoke-WinUtilDarkMode {
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Sets Dark Mode on or off
|
||||
|
||||
#>
|
||||
Param($DarkMoveEnabled)
|
||||
Try{
|
||||
if ($DarkMoveEnabled -eq $false){
|
||||
Write-Host "Enabling Dark Mode"
|
||||
$DarkMoveValue = 0
|
||||
}
|
||||
else {
|
||||
Write-Host "Disabling Dark Mode"
|
||||
$DarkMoveValue = 1
|
||||
}
|
||||
|
||||
$Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
|
||||
Set-ItemProperty -Path $Theme -Name AppsUseLightTheme -Value $DarkMoveValue
|
||||
Set-ItemProperty -Path $Theme -Name SystemUsesLightTheme -Value $DarkMoveValue
|
||||
}
|
||||
Catch [System.Security.SecurityException] {
|
||||
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
|
||||
}
|
||||
Catch [System.Management.Automation.ItemNotFoundException] {
|
||||
Write-Warning $psitem.Exception.ErrorRecord
|
||||
}
|
||||
Catch{
|
||||
Write-Warning "Unable to set $Name due to unhandled exception"
|
||||
Write-Warning $psitem.Exception.StackTrace
|
||||
}
|
||||
}
|
18
functions/private/Update-EnvironmentVariables
Normal file
18
functions/private/Update-EnvironmentVariables
Normal file
@ -0,0 +1,18 @@
|
||||
<#
|
||||
|
||||
.DESCRIPTION
|
||||
Updates Path Variables for the current session
|
||||
|
||||
#>
|
||||
|
||||
function Update-EnvironmentVariables {
|
||||
foreach($level in "Machine","User") {
|
||||
[Environment]::GetEnvironmentVariables($level).GetEnumerator() | % {
|
||||
# For Path variables, append the new values, if they're not already in there
|
||||
if($_.Name -match 'Path$') {
|
||||
$_.Value = ($((Get-Content "Env:$($_.Name)") + ";$($_.Value)") -split ';' | Select-Object -unique) -join ';'
|
||||
}
|
||||
$_
|
||||
} | Set-Content -Path { "Env:$($_.Name)" }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user