mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-12-22 14:01:31 -06: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:
parent
a44612378b
commit
a56aeefc7f
@ -40,6 +40,9 @@
|
|||||||
"Value": "0",
|
"Value": "0",
|
||||||
"OriginalValue": "1"
|
"OriginalValue": "1"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"InvokeScript": [
|
||||||
|
"powercfg.exe /hibernate off"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"WPFEssTweaksHome": {
|
"WPFEssTweaksHome": {
|
||||||
@ -92,7 +95,7 @@
|
|||||||
"service": [
|
"service": [
|
||||||
{
|
{
|
||||||
"Name": "AJRouter",
|
"Name": "AJRouter",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Disabled",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -132,7 +135,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "AssignedAccessManagerSvc",
|
"Name": "AssignedAccessManagerSvc",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Disabled",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -737,7 +740,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "SCardSvr",
|
"Name": "SCardSvr",
|
||||||
"StartupType": "Disabled",
|
"StartupType": "Manual",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -887,8 +890,8 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "TermService",
|
"Name": "TermService",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Automatic",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Automatic"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "TextInputManagementService",
|
"Name": "TextInputManagementService",
|
||||||
@ -1217,7 +1220,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "dmwappushservice",
|
"Name": "dmwappushservice",
|
||||||
"StartupType": "Disabled",
|
"StartupType": "Manual",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -1838,23 +1841,6 @@
|
|||||||
"type": "String"
|
"type": "String"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"service": [
|
|
||||||
{
|
|
||||||
"Name": "DiagTrack",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Automatic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "dmwappushservice",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Manual"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "SysMain",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Manual"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"InvokeScript": [
|
"InvokeScript": [
|
||||||
"bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
|
"bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
|
||||||
If ((get-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" -Name CurrentBuild).CurrentBuild -lt 22557) {
|
If ((get-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" -Name CurrentBuild).CurrentBuild -lt 22557) {
|
||||||
@ -1878,9 +1864,6 @@
|
|||||||
Remove-Item \"$autoLoggerDir\\AutoLogger-Diagtrack-Listener.etl\"
|
Remove-Item \"$autoLoggerDir\\AutoLogger-Diagtrack-Listener.etl\"
|
||||||
}
|
}
|
||||||
icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
|
icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
|
||||||
|
|
||||||
$ram = (Get-CimInstance -ClassName \"Win32_PhysicalMemory\" | Measure-Object -Property Capacity -Sum).Sum / 1kb
|
|
||||||
Set-ItemProperty -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\" -Name \"SvcHostSplitThresholdInKB\" -Type DWord -Value $ram -Force
|
|
||||||
"
|
"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -2237,7 +2220,10 @@
|
|||||||
},
|
},
|
||||||
"WPFEssTweaksDiskCleanup": {
|
"WPFEssTweaksDiskCleanup": {
|
||||||
"InvokeScript": [
|
"InvokeScript": [
|
||||||
"cleanmgr.exe /d C: /VERYLOWDISK"
|
"
|
||||||
|
cleanmgr.exe /d C: /VERYLOWDISK
|
||||||
|
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||||
|
"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"WPFMiscTweaksDisableTPMCheck": {
|
"WPFMiscTweaksDisableTPMCheck": {
|
||||||
@ -2374,11 +2360,7 @@
|
|||||||
"Value": "0",
|
"Value": "0",
|
||||||
"OriginalValue": "1",
|
"OriginalValue": "1",
|
||||||
"Type": "DWord"
|
"Type": "DWord"
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"WPFDisableGameBar": {
|
|
||||||
"registry": [
|
|
||||||
{
|
{
|
||||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR",
|
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR",
|
||||||
"Name": "AllowGameDVR",
|
"Name": "AllowGameDVR",
|
||||||
|
@ -67,11 +67,18 @@ foreach ($i in $remove_appx) {
|
|||||||
dir "$store\EndOfLife" -rec -ea 0 |where {$_ -like "*${i}*"} |foreach {cmd /c "reg delete ""$($_.Name)"" /f >nul 2>nul"}
|
dir "$store\EndOfLife" -rec -ea 0 |where {$_ -like "*${i}*"} |foreach {cmd /c "reg delete ""$($_.Name)"" /f >nul 2>nul"}
|
||||||
dir "$store\Deleted\EndOfLife" -rec -ea 0 |where {$_ -like "*${i}*"} |foreach {cmd /c "reg delete ""$($_.Name)"" /f >nul 2>nul"}
|
dir "$store\Deleted\EndOfLife" -rec -ea 0 |where {$_ -like "*${i}*"} |foreach {cmd /c "reg delete ""$($_.Name)"" /f >nul 2>nul"}
|
||||||
}
|
}
|
||||||
|
|
||||||
## extra cleanup
|
## extra cleanup
|
||||||
$desktop = $([Environment]::GetFolderPath('Desktop')); $appdata = $([Environment]::GetFolderPath('ApplicationData'))
|
$appdata = $([Environment]::GetFolderPath('ApplicationData'))
|
||||||
|
$desktop = $([Environment]::GetFolderPath('Desktop'))
|
||||||
|
$public_desktop = $([Environment]::GetFolderPath('CommonDesktopDirectory'))
|
||||||
|
$start_menu_programs = $([Environment]::GetFolderPath('CommonPrograms'))
|
||||||
del "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk" -force -ea 0
|
del "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Tombstones\Microsoft Edge.lnk" -force -ea 0
|
||||||
|
del "$appdata\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar\Microsoft Edge.lnk" -force -ea 0
|
||||||
del "$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk" -force -ea 0
|
del "$appdata\Microsoft\Internet Explorer\Quick Launch\Microsoft Edge.lnk" -force -ea 0
|
||||||
del "$desktop\Microsoft Edge.lnk" -force -ea 0
|
del "$desktop\Microsoft Edge.lnk" -force -ea 0
|
||||||
|
del "$public_desktop\Microsoft Edge.lnk" -force -ea 0
|
||||||
|
del "$start_menu_programs\Microsoft Edge.lnk" -force -ea 0
|
||||||
|
|
||||||
## add OpenWebSearch to redirect microsoft-edge: anti-competitive links to the default browser
|
## add OpenWebSearch to redirect microsoft-edge: anti-competitive links to the default browser
|
||||||
$IFEO = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
|
$IFEO = 'HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options'
|
||||||
|
@ -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 {
|
function Install-WinUtilWinget {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -28,46 +37,63 @@ function Install-WinUtilWinget {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
#Gets the Windows Edition
|
Write-Host "Running Alternative Installer and Direct Installing"
|
||||||
$OSName = if ($ComputerInfo.OSName) {
|
$ErrorActionPreference = "Stop"
|
||||||
$ComputerInfo.OSName
|
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
|
||||||
}else {
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$ComputerInfo.WindowsProductName
|
|
||||||
|
# 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")) {
|
$vcLibsUwp = @{
|
||||||
|
fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||||
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
url = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||||
|
hash = '6602159c341bafea747d0edf15669ac72df8817299fbfaa90469909e06794256'
|
||||||
# Switching to winget-install from PSGallery from asheroto
|
}
|
||||||
# Source: https://github.com/asheroto/winget-installer
|
$uiLibs = @{
|
||||||
|
nupkg = @{
|
||||||
#adding the code from the asheroto repo
|
fileName = 'microsoft.ui.xaml.2.7.0.nupkg'
|
||||||
Set-ExecutionPolicy RemoteSigned -force
|
url = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
|
||||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
hash = "422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591"
|
||||||
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
|
}
|
||||||
Install-Script -Name winget-install -force
|
uwp = @{
|
||||||
winget-instal
|
fileName = 'Microsoft.UI.Xaml.2.7.appx'
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$uiLibs.uwp.file = $PWD.Path + '\' + $uiLibs.uwp.fileName
|
||||||
|
$uiLibs.uwp.zipPath = '*/x64/*/' + $uiLibs.uwp.fileName
|
||||||
|
|
||||||
else {
|
$dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibs.nupkg)
|
||||||
#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
|
|
||||||
|
|
||||||
if(!(Test-WinUtilPackageManager -winget)){
|
foreach ($dependency in $dependencies) {
|
||||||
break
|
$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"
|
Write-Host "Winget Installed"
|
||||||
}
|
}
|
||||||
Catch{
|
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
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
Function Invoke-WPFDarkMode {
|
Function Invoke-WinUtilDarkMode {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
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)" }
|
||||||
|
}
|
||||||
|
}
|
23
functions/public/Invoke-WPFToggle.ps1
Normal file
23
functions/public/Invoke-WPFToggle.ps1
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
function Invoke-WPFToggle {
|
||||||
|
|
||||||
|
<#
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Meant to make creating toggle switches easier. There is a section below in the gui that will assign this function to every switch.
|
||||||
|
This way you can dictate what each button does from this function.
|
||||||
|
|
||||||
|
Input will be the name of the toggle that is checked.
|
||||||
|
#>
|
||||||
|
|
||||||
|
Param ([string]$Button)
|
||||||
|
|
||||||
|
#Use this to get the name of the button
|
||||||
|
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
|
||||||
|
|
||||||
|
Switch -Wildcard ($Button){
|
||||||
|
|
||||||
|
"WPFToggleDarkMode" {Invoke-WinUtilDarkMode -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)}
|
||||||
|
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
############################################################################
|
############################################################################
|
||||||
# This file was created with O&O ShutUp10++ V1.9.1434
|
# This file was created with O&O ShutUp10++ V1.9.1435
|
||||||
# and can be imported onto another computer.
|
# and can be imported onto another computer.
|
||||||
#
|
#
|
||||||
# Download the application at https://www.oo-software.com/shutup10
|
# Download the application at https://www.oo-software.com/shutup10
|
||||||
@ -13,7 +13,7 @@
|
|||||||
# user does not get any feedback about the import.
|
# user does not get any feedback about the import.
|
||||||
#
|
#
|
||||||
# We are always happy to answer any questions you may have!
|
# We are always happy to answer any questions you may have!
|
||||||
# © 2015-2022 O&O Software GmbH, Berlin. All rights reserved.
|
# © 2015-2023 O&O Software GmbH, Berlin. All rights reserved.
|
||||||
# https://www.oo-software.com/
|
# https://www.oo-software.com/
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ P013 -
|
|||||||
P035 -
|
P035 -
|
||||||
P062 -
|
P062 -
|
||||||
P063 -
|
P063 -
|
||||||
P081 +
|
P081 -
|
||||||
P047 -
|
P047 -
|
||||||
P019 -
|
P019 -
|
||||||
P048 -
|
P048 -
|
||||||
@ -102,7 +102,7 @@ P077 -
|
|||||||
P078 -
|
P078 -
|
||||||
P079 -
|
P079 -
|
||||||
P080 -
|
P080 -
|
||||||
P024 +
|
P024 -
|
||||||
S001 +
|
S001 +
|
||||||
S002 +
|
S002 +
|
||||||
S003 +
|
S003 +
|
||||||
@ -123,12 +123,14 @@ E109 +
|
|||||||
E209 +
|
E209 +
|
||||||
E121 +
|
E121 +
|
||||||
E221 -
|
E221 -
|
||||||
E103 +
|
E103 -
|
||||||
E203 -
|
E203 -
|
||||||
E123 -
|
E123 -
|
||||||
E223 +
|
E223 +
|
||||||
E124 -
|
E124 -
|
||||||
E224 -
|
E224 -
|
||||||
|
E128 -
|
||||||
|
E228 -
|
||||||
E119 -
|
E119 -
|
||||||
E219 -
|
E219 -
|
||||||
E120 -
|
E120 -
|
||||||
@ -145,10 +147,10 @@ E127 -
|
|||||||
E227 -
|
E227 -
|
||||||
E001 +
|
E001 +
|
||||||
E002 +
|
E002 +
|
||||||
E003 +
|
E003 -
|
||||||
E008 +
|
E008 +
|
||||||
E007 +
|
E007 +
|
||||||
E010 +
|
E010 -
|
||||||
E011 +
|
E011 +
|
||||||
E012 +
|
E012 +
|
||||||
E009 -
|
E009 -
|
||||||
@ -157,22 +159,6 @@ E005 -
|
|||||||
E013 -
|
E013 -
|
||||||
E014 -
|
E014 -
|
||||||
E006 -
|
E006 -
|
||||||
F002 -
|
|
||||||
F014 +
|
|
||||||
F015 -
|
|
||||||
F016 -
|
|
||||||
F001 -
|
|
||||||
F003 +
|
|
||||||
F004 +
|
|
||||||
F005 +
|
|
||||||
F007 -
|
|
||||||
F008 -
|
|
||||||
F009 -
|
|
||||||
F006 -
|
|
||||||
F010 -
|
|
||||||
F011 -
|
|
||||||
F012 -
|
|
||||||
F013 -
|
|
||||||
Y001 +
|
Y001 +
|
||||||
Y002 +
|
Y002 +
|
||||||
Y003 +
|
Y003 +
|
||||||
@ -222,6 +208,7 @@ M022 +
|
|||||||
M001 +
|
M001 +
|
||||||
M004 +
|
M004 +
|
||||||
M005 +
|
M005 +
|
||||||
|
M024 -
|
||||||
M003 -
|
M003 -
|
||||||
M012 -
|
M012 -
|
||||||
M013 -
|
M013 -
|
||||||
@ -234,4 +221,3 @@ M019 -
|
|||||||
M020 +
|
M020 +
|
||||||
M021 -
|
M021 -
|
||||||
N001 -
|
N001 -
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#Configure max thread count for RunspacePool.
|
#Configure max thread count for RunspacePool.
|
||||||
$maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
$maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
@ -47,14 +49,14 @@ $sync.runspace.Open()
|
|||||||
#endregion exception classes
|
#endregion exception classes
|
||||||
|
|
||||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||||
$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 ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True){
|
||||||
if($app -eq 0 -and $system -eq 0){
|
|
||||||
$ctttheme = 'Matrix'
|
$ctttheme = 'Matrix'
|
||||||
}
|
}
|
||||||
else{
|
Else{
|
||||||
$ctttheme = 'Classic'
|
$ctttheme = 'Classic'
|
||||||
}
|
}
|
||||||
|
|
||||||
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
||||||
|
|
||||||
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
||||||
@ -92,11 +94,23 @@ $sync.keys | ForEach-Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync["WPFToggleDarkMode"].Add_Click({
|
|
||||||
Invoke-WPFDarkMode -DarkMoveEnabled $(Get-WinUtilDarkMode)
|
|
||||||
})
|
|
||||||
|
|
||||||
$sync["WPFToggleDarkMode"].IsChecked = Get-WinUtilDarkMode
|
$sync.keys | ForEach-Object {
|
||||||
|
if($sync.$psitem){
|
||||||
|
if(
|
||||||
|
$($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
|
||||||
|
-and $sync["$psitem"].Name -like "WPFToggle*"
|
||||||
|
){
|
||||||
|
$sync["$psitem"].IsChecked = Get-WinUtilToggleStatus $sync["$psitem"].Name
|
||||||
|
|
||||||
|
$sync["$psitem"].Add_Click({
|
||||||
|
[System.Object]$Sender = $args[0]
|
||||||
|
Invoke-WPFToggle $Sender.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Setup background config
|
# Setup background config
|
||||||
|
358
winutil.ps1
358
winutil.ps1
@ -100,22 +100,6 @@ Function Get-WinUtilCheckBoxes {
|
|||||||
|
|
||||||
Write-Output $($Output | Select-Object -Unique)
|
Write-Output $($Output | Select-Object -Unique)
|
||||||
}
|
}
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function Get-WinUtilInstallerProcess {
|
function Get-WinUtilInstallerProcess {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
@ -167,6 +151,38 @@ function Get-WinUtilRegistry {
|
|||||||
Write-Warning $psitem.Exception.StackTrace
|
Write-Warning $psitem.Exception.StackTrace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
function Get-WinUtilVariables {
|
function Get-WinUtilVariables {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -263,6 +279,15 @@ Function Install-WinUtilProgramWinget {
|
|||||||
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
Write-Progress -Activity "$manage Applications" -Status "Finished" -Completed
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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 {
|
function Install-WinUtilWinget {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -293,52 +318,100 @@ function Install-WinUtilWinget {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
#Gets the Windows Edition
|
Write-Host "Running Alternative Installer and Direct Installing"
|
||||||
$OSName = if ($ComputerInfo.OSName) {
|
$ErrorActionPreference = "Stop"
|
||||||
$ComputerInfo.OSName
|
$apiLatestUrl = 'https://api.github.com/repos/microsoft/winget-cli/releases/latest'
|
||||||
}else {
|
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
|
||||||
$ComputerInfo.WindowsProductName
|
|
||||||
|
# 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")) {
|
$vcLibsUwp = @{
|
||||||
|
fileName = 'Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||||
Write-Host "Running Alternative Installer for LTSC/Server Editions"
|
url = 'https://aka.ms/Microsoft.VCLibs.x64.14.00.Desktop.appx'
|
||||||
|
hash = '6602159c341bafea747d0edf15669ac72df8817299fbfaa90469909e06794256'
|
||||||
# Switching to winget-install from PSGallery from asheroto
|
}
|
||||||
# Source: https://github.com/asheroto/winget-installer
|
$uiLibs = @{
|
||||||
|
nupkg = @{
|
||||||
#adding the code from the asheroto repo
|
fileName = 'microsoft.ui.xaml.2.7.0.nupkg'
|
||||||
Set-ExecutionPolicy RemoteSigned -force
|
url = 'https://www.nuget.org/api/v2/package/Microsoft.UI.Xaml/2.7.0'
|
||||||
Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
|
hash = "422FD24B231E87A842C4DAEABC6A335112E0D35B86FAC91F5CE7CF327E36A591"
|
||||||
Set-PSRepository -Name 'PSGallery' -InstallationPolicy Trusted
|
}
|
||||||
Install-Script -Name winget-install -force
|
uwp = @{
|
||||||
winget-instal
|
fileName = 'Microsoft.UI.Xaml.2.7.appx'
|
||||||
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$uiLibs.uwp.file = $PWD.Path + '\' + $uiLibs.uwp.fileName
|
||||||
|
$uiLibs.uwp.zipPath = '*/x64/*/' + $uiLibs.uwp.fileName
|
||||||
|
|
||||||
else {
|
$dependencies = @($desktopAppInstaller, $vcLibsUwp, $uiLibs.nupkg)
|
||||||
#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
|
|
||||||
|
|
||||||
if(!(Test-WinUtilPackageManager -winget)){
|
foreach ($dependency in $dependencies) {
|
||||||
break
|
$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"
|
Write-Host "Winget Installed"
|
||||||
}
|
}
|
||||||
Catch{
|
Catch{
|
||||||
throw [WingetFailedInstall]::new('Failed to install')
|
throw [WingetFailedInstall]::new('Failed to install')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
Function Invoke-WinUtilCurrentSystem {
|
Function Invoke-WinUtilCurrentSystem {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -443,6 +516,39 @@ Function Invoke-WinUtilCurrentSystem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
function Invoke-WinUtilFeatureInstall {
|
function Invoke-WinUtilFeatureInstall {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
@ -863,6 +969,24 @@ function Test-WinUtilPackageManager {
|
|||||||
|
|
||||||
return $false
|
return $false
|
||||||
}
|
}
|
||||||
|
<#
|
||||||
|
|
||||||
|
.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)" }
|
||||||
|
}
|
||||||
|
}
|
||||||
Function Update-WinUtilProgramWinget {
|
Function Update-WinUtilProgramWinget {
|
||||||
|
|
||||||
<#
|
<#
|
||||||
@ -958,39 +1082,6 @@ function Invoke-WPFControlPanel {
|
|||||||
"WPFPaneluser" {cmd /c "control userpasswords2"}
|
"WPFPaneluser" {cmd /c "control userpasswords2"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Function Invoke-WPFDarkMode {
|
|
||||||
<#
|
|
||||||
|
|
||||||
.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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function Invoke-WPFFeatureInstall {
|
function Invoke-WPFFeatureInstall {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
@ -1511,6 +1602,29 @@ function Invoke-WPFTab {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function Invoke-WPFToggle {
|
||||||
|
|
||||||
|
<#
|
||||||
|
|
||||||
|
.DESCRIPTION
|
||||||
|
Meant to make creating toggle switches easier. There is a section below in the gui that will assign this function to every switch.
|
||||||
|
This way you can dictate what each button does from this function.
|
||||||
|
|
||||||
|
Input will be the name of the toggle that is checked.
|
||||||
|
#>
|
||||||
|
|
||||||
|
Param ([string]$Button)
|
||||||
|
|
||||||
|
#Use this to get the name of the button
|
||||||
|
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
|
||||||
|
|
||||||
|
Switch -Wildcard ($Button){
|
||||||
|
|
||||||
|
"WPFToggleDarkMode" {Invoke-WinUtilDarkMode -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)}
|
||||||
|
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
function Invoke-WPFtweaksbutton {
|
function Invoke-WPFtweaksbutton {
|
||||||
<#
|
<#
|
||||||
|
|
||||||
@ -2474,6 +2588,12 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
|
|||||||
<Label Content="Off" />
|
<Label Content="Off" />
|
||||||
<CheckBox Name="WPFToggleDarkMode" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
<CheckBox Name="WPFToggleDarkMode" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
||||||
<Label Content="On" />
|
<Label Content="On" />
|
||||||
|
</StackPanel>
|
||||||
|
<Label Content="Bing Search in Start Menu" />
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Label Content="Off" />
|
||||||
|
<CheckBox Name="WPFToggleBingSearch" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
||||||
|
<Label Content="On" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Label Content="Performance Plans" />
|
<Label Content="Performance Plans" />
|
||||||
<Button Name="WPFAddUltPerf" Content="Add Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,2" Width="300"/>
|
<Button Name="WPFAddUltPerf" Content="Add Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,2" Width="300"/>
|
||||||
@ -3346,6 +3466,9 @@ $sync.configs.tweaks = '{
|
|||||||
"Value": "0",
|
"Value": "0",
|
||||||
"OriginalValue": "1"
|
"OriginalValue": "1"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"InvokeScript": [
|
||||||
|
"powercfg.exe /hibernate off"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"WPFEssTweaksHome": {
|
"WPFEssTweaksHome": {
|
||||||
@ -3398,7 +3521,7 @@ $sync.configs.tweaks = '{
|
|||||||
"service": [
|
"service": [
|
||||||
{
|
{
|
||||||
"Name": "AJRouter",
|
"Name": "AJRouter",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Disabled",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -3438,7 +3561,7 @@ $sync.configs.tweaks = '{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "AssignedAccessManagerSvc",
|
"Name": "AssignedAccessManagerSvc",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Disabled",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -4043,7 +4166,7 @@ $sync.configs.tweaks = '{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "SCardSvr",
|
"Name": "SCardSvr",
|
||||||
"StartupType": "Disabled",
|
"StartupType": "Manual",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -4193,8 +4316,8 @@ $sync.configs.tweaks = '{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "TermService",
|
"Name": "TermService",
|
||||||
"StartupType": "Manual",
|
"StartupType": "Automatic",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Automatic"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "TextInputManagementService",
|
"Name": "TextInputManagementService",
|
||||||
@ -4523,7 +4646,7 @@ $sync.configs.tweaks = '{
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Name": "dmwappushservice",
|
"Name": "dmwappushservice",
|
||||||
"StartupType": "Disabled",
|
"StartupType": "Manual",
|
||||||
"OriginalType": "Manual"
|
"OriginalType": "Manual"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -5144,23 +5267,6 @@ $sync.configs.tweaks = '{
|
|||||||
"type": "String"
|
"type": "String"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"service": [
|
|
||||||
{
|
|
||||||
"Name": "DiagTrack",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Automatic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "dmwappushservice",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Manual"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Name": "SysMain",
|
|
||||||
"StartupType": "Disabled",
|
|
||||||
"OriginalType": "Manual"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"InvokeScript": [
|
"InvokeScript": [
|
||||||
"bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
|
"bcdedit /set `{current`} bootmenupolicy Legacy | Out-Null
|
||||||
If ((get-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" -Name CurrentBuild).CurrentBuild -lt 22557) {
|
If ((get-ItemProperty -Path \"HKLM:\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\" -Name CurrentBuild).CurrentBuild -lt 22557) {
|
||||||
@ -5184,9 +5290,6 @@ $sync.configs.tweaks = '{
|
|||||||
Remove-Item \"$autoLoggerDir\\AutoLogger-Diagtrack-Listener.etl\"
|
Remove-Item \"$autoLoggerDir\\AutoLogger-Diagtrack-Listener.etl\"
|
||||||
}
|
}
|
||||||
icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
|
icacls $autoLoggerDir /deny SYSTEM:`(OI`)`(CI`)F | Out-Null
|
||||||
|
|
||||||
$ram = (Get-CimInstance -ClassName \"Win32_PhysicalMemory\" | Measure-Object -Property Capacity -Sum).Sum / 1kb
|
|
||||||
Set-ItemProperty -Path \"HKLM:\\SYSTEM\\CurrentControlSet\\Control\" -Name \"SvcHostSplitThresholdInKB\" -Type DWord -Value $ram -Force
|
|
||||||
"
|
"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
@ -5543,7 +5646,10 @@ $sync.configs.tweaks = '{
|
|||||||
},
|
},
|
||||||
"WPFEssTweaksDiskCleanup": {
|
"WPFEssTweaksDiskCleanup": {
|
||||||
"InvokeScript": [
|
"InvokeScript": [
|
||||||
"cleanmgr.exe /d C: /VERYLOWDISK"
|
"
|
||||||
|
cleanmgr.exe /d C: /VERYLOWDISK
|
||||||
|
Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
|
||||||
|
"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"WPFMiscTweaksDisableTPMCheck": {
|
"WPFMiscTweaksDisableTPMCheck": {
|
||||||
@ -5680,11 +5786,7 @@ $sync.configs.tweaks = '{
|
|||||||
"Value": "0",
|
"Value": "0",
|
||||||
"OriginalValue": "1",
|
"OriginalValue": "1",
|
||||||
"Type": "DWord"
|
"Type": "DWord"
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"WPFDisableGameBar": {
|
|
||||||
"registry": [
|
|
||||||
{
|
{
|
||||||
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR",
|
"Path": "HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\GameDVR",
|
||||||
"Name": "AllowGameDVR",
|
"Name": "AllowGameDVR",
|
||||||
@ -5706,6 +5808,8 @@ $sync.configs.tweaks = '{
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
}' | convertfrom-json
|
}' | convertfrom-json
|
||||||
|
# SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
#Configure max thread count for RunspacePool.
|
#Configure max thread count for RunspacePool.
|
||||||
$maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
$maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
||||||
|
|
||||||
@ -5755,14 +5859,14 @@ $sync.runspace.Open()
|
|||||||
#endregion exception classes
|
#endregion exception classes
|
||||||
|
|
||||||
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
$inputXML = $inputXML -replace 'mc:Ignorable="d"', '' -replace "x:N", 'N' -replace '^<Win.*', '<Window'
|
||||||
$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 ((Get-WinUtilToggleStatus WPFToggleDarkMode) -eq $True){
|
||||||
if($app -eq 0 -and $system -eq 0){
|
|
||||||
$ctttheme = 'Matrix'
|
$ctttheme = 'Matrix'
|
||||||
}
|
}
|
||||||
else{
|
Else{
|
||||||
$ctttheme = 'Classic'
|
$ctttheme = 'Classic'
|
||||||
}
|
}
|
||||||
|
|
||||||
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
$inputXML = Set-WinUtilUITheme -inputXML $inputXML -themeName $ctttheme
|
||||||
|
|
||||||
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
[void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
|
||||||
@ -5800,11 +5904,23 @@ $sync.keys | ForEach-Object {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync["WPFToggleDarkMode"].Add_Click({
|
|
||||||
Invoke-WPFDarkMode -DarkMoveEnabled $(Get-WinUtilDarkMode)
|
|
||||||
})
|
|
||||||
|
|
||||||
$sync["WPFToggleDarkMode"].IsChecked = Get-WinUtilDarkMode
|
$sync.keys | ForEach-Object {
|
||||||
|
if($sync.$psitem){
|
||||||
|
if(
|
||||||
|
$($sync["$psitem"].GetType() | Select-Object -ExpandProperty Name) -eq "CheckBox" `
|
||||||
|
-and $sync["$psitem"].Name -like "WPFToggle*"
|
||||||
|
){
|
||||||
|
$sync["$psitem"].IsChecked = Get-WinUtilToggleStatus $sync["$psitem"].Name
|
||||||
|
|
||||||
|
$sync["$psitem"].Add_Click({
|
||||||
|
[System.Object]$Sender = $args[0]
|
||||||
|
Invoke-WPFToggle $Sender.name
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#===========================================================================
|
#===========================================================================
|
||||||
# Setup background config
|
# Setup background config
|
||||||
|
@ -465,6 +465,12 @@
|
|||||||
<Label Content="Off" />
|
<Label Content="Off" />
|
||||||
<CheckBox Name="WPFToggleDarkMode" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
<CheckBox Name="WPFToggleDarkMode" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
||||||
<Label Content="On" />
|
<Label Content="On" />
|
||||||
|
</StackPanel>
|
||||||
|
<Label Content="Bing Search in Start Menu" />
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<Label Content="Off" />
|
||||||
|
<CheckBox Name="WPFToggleBingSearch" Style="{StaticResource ToggleSwitchStyle}" Margin="2.5,0"/>
|
||||||
|
<Label Content="On" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
<Label Content="Performance Plans" />
|
<Label Content="Performance Plans" />
|
||||||
<Button Name="WPFAddUltPerf" Content="Add Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,2" Width="300"/>
|
<Button Name="WPFAddUltPerf" Content="Add Ultimate Performance Profile" HorizontalAlignment = "Left" Margin="5,2" Width="300"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user