nul"
26 | $charactersArray = @()
27 | $regexPattern = '([a-zA-Z])'
28 | $charactersArray = [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
29 |
30 | Write-Debug "According to takeown.exe local Yes is $charactersArray[0]"
31 | # Return the array of characters
32 | return $charactersArray
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/functions/private/Get-Oscdimg.ps1:
--------------------------------------------------------------------------------
1 | function Get-Oscdimg {
2 | <#
3 | .DESCRIPTION
4 | This function will download oscdimg file from github Release folders and put it into env:temp folder
5 |
6 | .EXAMPLE
7 | Get-Oscdimg
8 | #>
9 |
10 | param(
11 | [Parameter(Mandatory, position=0)]
12 | [string]$oscdimgPath
13 | )
14 |
15 | $oscdimgPath = "$env:TEMP\oscdimg.exe"
16 | $downloadUrl = "https://github.com/ChrisTitusTech/winutil/raw/main/releases/oscdimg.exe"
17 | Invoke-RestMethod -Uri $downloadUrl -OutFile $oscdimgPath
18 | $hashResult = Get-FileHash -Path $oscdimgPath -Algorithm SHA256
19 | $sha256Hash = $hashResult.Hash
20 |
21 | Write-Host "[INFO] oscdimg.exe SHA-256 Hash: $sha256Hash"
22 |
23 | $expectedHash = "AB9E161049D293B544961BFDF2D61244ADE79376D6423DF4F60BF9B147D3C78D" # Replace with the actual expected hash
24 | if ($sha256Hash -eq $expectedHash) {
25 | Write-Host "Hashes match. File is verified."
26 | } else {
27 | Write-Host "Hashes do not match. File may be corrupted or tampered with."
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/functions/private/Get-WPFObjectName.ps1:
--------------------------------------------------------------------------------
1 | function Get-WPFObjectName {
2 | <#
3 | .SYNOPSIS
4 | This is a helper function that generates an objectname with the prefix WPF that can be used as a Powershell Variable after compilation.
5 | To achieve this, all characters that are not a-z, A-Z or 0-9 are simply removed from the name.
6 |
7 | .PARAMETER type
8 | The type of object for which the name should be generated. (e.g. Label, Button, CheckBox...)
9 |
10 | .PARAMETER name
11 | The name or description to be used for the object. (invalid characters are removed)
12 |
13 | .OUTPUTS
14 | A string that can be used as a object/variable name in powershell.
15 | For example: WPFLabelMicrosoftTools
16 |
17 | .EXAMPLE
18 | Get-WPFObjectName -type Label -name "Microsoft Tools"
19 | #>
20 |
21 | param(
22 | [Parameter(Mandatory, position=0)]
23 | [string]$type,
24 |
25 | [Parameter(position=1)]
26 | [string]$name
27 | )
28 |
29 | $Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
30 | return $Output
31 | }
32 |
--------------------------------------------------------------------------------
/functions/private/Get-WinUtilInstallerProcess.ps1:
--------------------------------------------------------------------------------
1 | function Get-WinUtilInstallerProcess {
2 | <#
3 |
4 | .SYNOPSIS
5 | Checks if the given process is running
6 |
7 | .PARAMETER Process
8 | The process to check
9 |
10 | .OUTPUTS
11 | Boolean - True if the process is running
12 |
13 | #>
14 |
15 | param($Process)
16 |
17 | if ($Null -eq $Process) {
18 | return $false
19 | }
20 | if (Get-Process -Id $Process.Id -ErrorAction SilentlyContinue) {
21 | return $true
22 | }
23 | return $false
24 | }
25 |
--------------------------------------------------------------------------------
/functions/private/Get-WinUtilVariables.ps1:
--------------------------------------------------------------------------------
1 | function Get-WinUtilVariables {
2 |
3 | <#
4 | .SYNOPSIS
5 | Gets every form object of the provided type
6 |
7 | .OUTPUTS
8 | List containing every object that matches the provided type
9 | #>
10 | param (
11 | [Parameter()]
12 | [string[]]$Type
13 | )
14 | $keys = ($sync.keys).where{ $_ -like "WPF*" }
15 | if ($Type) {
16 | $output = $keys | ForEach-Object {
17 | try {
18 | $objType = $sync["$psitem"].GetType().Name
19 | if ($Type -contains $objType) {
20 | Write-Output $psitem
21 | }
22 | } catch {
23 | <#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>
24 | }
25 | }
26 | return $output
27 | }
28 | return $keys
29 | }
30 |
--------------------------------------------------------------------------------
/functions/private/Get-WinUtilWingetLatest.ps1:
--------------------------------------------------------------------------------
1 | function Get-WinUtilWingetLatest {
2 | <#
3 | .SYNOPSIS
4 | Uses GitHub API to check for the latest release of Winget.
5 | .DESCRIPTION
6 | This function grabs the latest version of Winget and returns the download path to Install-WinUtilWinget for installation.
7 | #>
8 | # Invoke-WebRequest is notoriously slow when the byte progress is displayed. The following lines disable the progress bar and reset them at the end of the function
9 | $PreviousProgressPreference = $ProgressPreference
10 | $ProgressPreference = "silentlyContinue"
11 | try {
12 | # Grabs the latest release of Winget from the Github API for the install process.
13 | $response = Invoke-RestMethod -Uri "https://api.github.com/repos/microsoft/Winget-cli/releases/latest" -Method Get -ErrorAction Stop
14 | $latestVersion = $response.tag_name #Stores version number of latest release.
15 | $licenseWingetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*License1.xml"} #Index value for License file.
16 | Write-Host "Latest Version:`t$($latestVersion)`n"
17 | Write-Host "Downloading..."
18 | $assetUrl = $response.assets.browser_download_url | Where-Object {$_ -like "*Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.msixbundle"}
19 | Invoke-WebRequest -Uri $licenseWingetUrl -OutFile $ENV:TEMP\License1.xml
20 | # The only pain is that the msixbundle for winget-cli is 246MB. In some situations this can take a bit, with slower connections.
21 | Invoke-WebRequest -Uri $assetUrl -OutFile $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle
22 | } catch {
23 | throw [WingetFailedInstall]::new('Failed to get latest Winget release and license')
24 | }
25 | $ProgressPreference = $PreviousProgressPreference
26 | }
27 |
--------------------------------------------------------------------------------
/functions/private/Get-WinUtilWingetPrerequisites.ps1:
--------------------------------------------------------------------------------
1 | function Get-WinUtilWingetPrerequisites {
2 | <#
3 | .SYNOPSIS
4 | Downloads the Winget Prereqs.
5 | .DESCRIPTION
6 | Downloads Prereqs for Winget. Version numbers are coded as variables and can be updated as uncommonly as Microsoft updates the prereqs.
7 | #>
8 |
9 | # I don't know of a way to detect the prereqs automatically, so if someone has a better way of defining these, that would be great.
10 | # Microsoft.VCLibs version rarely changes, but for future compatibility I made it a variable.
11 | $versionVCLibs = "14.00"
12 | $fileVCLibs = "https://aka.ms/Microsoft.VCLibs.x64.${versionVCLibs}.Desktop.appx"
13 | # Write-Host "$fileVCLibs"
14 | # Microsoft.UI.Xaml version changed recently, so I made the version numbers variables.
15 | $versionUIXamlMinor = "2.8"
16 | $versionUIXamlPatch = "2.8.6"
17 | $fileUIXaml = "https://github.com/microsoft/microsoft-ui-xaml/releases/download/v${versionUIXamlPatch}/Microsoft.UI.Xaml.${versionUIXamlMinor}.x64.appx"
18 | # Write-Host "$fileUIXaml"
19 |
20 | try {
21 | Write-Host "Downloading Microsoft.VCLibs Dependency..."
22 | Invoke-WebRequest -Uri $fileVCLibs -OutFile $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx
23 | Write-Host "Downloading Microsoft.UI.Xaml Dependency...`n"
24 | Invoke-WebRequest -Uri $fileUIXaml -OutFile $ENV:TEMP\Microsoft.UI.Xaml.x64.appx
25 | } catch {
26 | throw [WingetFailedInstall]::new('Failed to install prerequsites')
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/functions/private/Install-WinUtilChoco.ps1:
--------------------------------------------------------------------------------
1 | function Install-WinUtilChoco {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Installs Chocolatey if it is not already installed
7 |
8 | #>
9 |
10 | try {
11 | Write-Host "Checking if Chocolatey is Installed..."
12 |
13 | if((Test-WinUtilPackageManager -choco) -eq "installed") {
14 | return
15 | }
16 | # Install logic taken from https://chocolatey.org/install#individual
17 | Write-Host "Seems Chocolatey is not installed, installing now."
18 | Set-ExecutionPolicy Bypass -Scope Process -Force;
19 | [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
20 | Invoke-Expression ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
21 |
22 | } catch {
23 | Write-Host "===========================================" -Foregroundcolor Red
24 | Write-Host "-- Chocolatey failed to install ---" -Foregroundcolor Red
25 | Write-Host "===========================================" -Foregroundcolor Red
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilBingSearch.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilBingSearch {
2 | <#
3 |
4 | .SYNOPSIS
5 | Disables/Enables Bing Search
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to enable or disable Bing Search
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Enabling Bing Search"
15 | $value = 1
16 | } else {
17 | Write-Host "Disabling Bing Search"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search"
21 | Set-ItemProperty -Path $Path -Name BingSearchEnabled -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilDarkMode.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WinUtilDarkMode {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enables/Disables Dark Mode
6 |
7 | .PARAMETER DarkMoveEnabled
8 | Indicates the current dark mode state
9 |
10 | #>
11 | Param($DarkMoveEnabled)
12 | try {
13 | if ($DarkMoveEnabled -eq $false) {
14 | Write-Host "Enabling Dark Mode"
15 | $DarkMoveValue = 0
16 | } else {
17 | Write-Host "Disabling Dark Mode"
18 | $DarkMoveValue = 1
19 | }
20 |
21 | $Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
22 | Set-ItemProperty -Path $Path -Name AppsUseLightTheme -Value $DarkMoveValue
23 | Set-ItemProperty -Path $Path -Name SystemUsesLightTheme -Value $DarkMoveValue
24 | } catch [System.Security.SecurityException] {
25 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
26 | } catch [System.Management.Automation.ItemNotFoundException] {
27 | Write-Warning $psitem.Exception.ErrorRecord
28 | } catch {
29 | Write-Warning "Unable to set $Name due to unhandled exception"
30 | Write-Warning $psitem.Exception.StackTrace
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilDetailedBSoD.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WinUtilDetailedBSoD {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enables/Disables Detailed BSoD
6 | (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl' -Name 'DisplayParameters').DisplayParameters
7 |
8 |
9 | #>
10 | Param($Enabled)
11 | try {
12 | if ($Enabled -eq $false) {
13 | Write-Host "Enabling Detailed BSoD"
14 | $value = 1
15 | } else {
16 | Write-Host "Disabling Detailed BSoD"
17 | $value =0
18 | }
19 |
20 | $Path = "HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl"
21 | $dwords = ("DisplayParameters", "DisableEmoticon")
22 | foreach ($name in $dwords) {
23 | Set-ItemProperty -Path $Path -Name $name -Value $value
24 | }
25 | Set-ItemProperty -Path $Path -Name DisplayParameters -Value $value
26 | } catch [System.Security.SecurityException] {
27 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
28 | } catch [System.Management.Automation.ItemNotFoundException] {
29 | Write-Warning $psitem.Exception.ErrorRecord
30 | } catch {
31 | Write-Warning "Unable to set $Name due to unhandled exception"
32 | Write-Warning $psitem.Exception.StackTrace
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilFeatureInstall.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilFeatureInstall {
2 | <#
3 |
4 | .SYNOPSIS
5 | Converts all the values from the tweaks.json and routes them to the appropriate function
6 |
7 | #>
8 |
9 | param(
10 | $CheckBox
11 | )
12 |
13 | $x = 0
14 |
15 | $CheckBox | ForEach-Object {
16 | if($sync.configs.feature.$psitem.feature) {
17 | Foreach( $feature in $sync.configs.feature.$psitem.feature ) {
18 | try {
19 | Write-Host "Installing $feature"
20 | Enable-WindowsOptionalFeature -Online -FeatureName $feature -All -NoRestart
21 | } catch {
22 | if ($psitem.Exception.Message -like "*requires elevation*") {
23 | Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
24 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
25 | } else {
26 |
27 | Write-Warning "Unable to Install $feature due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 | }
32 | }
33 | if($sync.configs.feature.$psitem.InvokeScript) {
34 | Foreach( $script in $sync.configs.feature.$psitem.InvokeScript ) {
35 | try {
36 | $Scriptblock = [scriptblock]::Create($script)
37 |
38 | Write-Host "Running Script for $psitem"
39 | Invoke-Command $scriptblock -ErrorAction stop
40 | } catch {
41 | if ($psitem.Exception.Message -like "*requires elevation*") {
42 | Write-Warning "Unable to Install $feature due to permissions. Are you running as admin?"
43 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
44 | } else {
45 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Error" })
46 | Write-Warning "Unable to Install $feature due to unhandled exception"
47 | Write-Warning $psitem.Exception.StackTrace
48 | }
49 | }
50 | }
51 | }
52 | $X++
53 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($x/$CheckBox.Count) })
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilGPU.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilGPU {
2 | $gpuInfo = Get-CimInstance Win32_VideoController
3 |
4 | # GPUs to blacklist from using Demanding Theming
5 | $lowPowerGPUs = (
6 | "*NVIDIA GeForce*M*",
7 | "*NVIDIA GeForce*Laptop*",
8 | "*NVIDIA GeForce*GT*",
9 | "*AMD Radeon(TM)*",
10 | "*Intel(R) HD Graphics*",
11 | "*UHD*"
12 |
13 | )
14 |
15 | foreach ($gpu in $gpuInfo) {
16 | foreach ($gpuPattern in $lowPowerGPUs) {
17 | if ($gpu.Name -like $gpuPattern) {
18 | return $false
19 | }
20 | }
21 | }
22 | return $true
23 | }
24 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilHiddenFiles.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilHiddenFiles {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enable/Disable Hidden Files
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to enable or disable Hidden Files
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Enabling Hidden Files"
15 | $value = 1
16 | } else {
17 | Write-Host "Disabling Hidden Files"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
21 | Set-ItemProperty -Path $Path -Name Hidden -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilMouseAcceleration.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WinUtilMouseAcceleration {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enables/Disables Mouse Acceleration
6 |
7 | .PARAMETER DarkMoveEnabled
8 | Indicates the current Mouse Acceleration State
9 |
10 | #>
11 | Param($MouseAccelerationEnabled)
12 | try {
13 | if ($MouseAccelerationEnabled -eq $false) {
14 | Write-Host "Enabling Mouse Acceleration"
15 | $MouseSpeed = 1
16 | $MouseThreshold1 = 6
17 | $MouseThreshold2 = 10
18 | } else {
19 | Write-Host "Disabling Mouse Acceleration"
20 | $MouseSpeed = 0
21 | $MouseThreshold1 = 0
22 | $MouseThreshold2 = 0
23 |
24 | }
25 |
26 | $Path = "HKCU:\Control Panel\Mouse"
27 | Set-ItemProperty -Path $Path -Name MouseSpeed -Value $MouseSpeed
28 | Set-ItemProperty -Path $Path -Name MouseThreshold1 -Value $MouseThreshold1
29 | Set-ItemProperty -Path $Path -Name MouseThreshold2 -Value $MouseThreshold2
30 | } catch [System.Security.SecurityException] {
31 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
32 | } catch [System.Management.Automation.ItemNotFoundException] {
33 | Write-Warning $psitem.Exception.ErrorRecord
34 | } catch {
35 | Write-Warning "Unable to set $Name due to unhandled exception"
36 | Write-Warning $psitem.Exception.StackTrace
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilNumLock.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilNumLock {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables NumLock on startup
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Numlock on startup
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Numlock on startup"
12 | $value = 2
13 | } else {
14 | Write-Host "Disabling Numlock on startup"
15 | $value = 0
16 | }
17 | New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
18 | $HKUPath = "HKU:\.Default\Control Panel\Keyboard"
19 | $HKCUPath = "HKCU:\Control Panel\Keyboard"
20 | Set-ItemProperty -Path $HKUPath -Name InitialKeyboardIndicators -Value $value
21 | Set-ItemProperty -Path $HKCUPath -Name InitialKeyboardIndicators -Value $value
22 | }
23 | Catch [System.Security.SecurityException] {
24 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
25 | } catch [System.Management.Automation.ItemNotFoundException] {
26 | Write-Warning $psitem.Exception.ErrorRecord
27 | } catch {
28 | Write-Warning "Unable to set $Name due to unhandled exception"
29 | Write-Warning $psitem.Exception.StackTrace
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilScript.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilScript {
2 | <#
3 |
4 | .SYNOPSIS
5 | Invokes the provided scriptblock. Intended for things that can't be handled with the other functions.
6 |
7 | .PARAMETER Name
8 | The name of the scriptblock being invoked
9 |
10 | .PARAMETER scriptblock
11 | The scriptblock to be invoked
12 |
13 | .EXAMPLE
14 | $Scriptblock = [scriptblock]::Create({"Write-output 'Hello World'"})
15 | Invoke-WinUtilScript -ScriptBlock $scriptblock -Name "Hello World"
16 |
17 | #>
18 | param (
19 | $Name,
20 | [scriptblock]$scriptblock
21 | )
22 |
23 | try {
24 | Write-Host "Running Script for $name"
25 | Invoke-Command $scriptblock -ErrorAction Stop
26 | } catch [System.Management.Automation.CommandNotFoundException] {
27 | Write-Warning "The specified command was not found."
28 | Write-Warning $PSItem.Exception.message
29 | } catch [System.Management.Automation.RuntimeException] {
30 | Write-Warning "A runtime exception occurred."
31 | Write-Warning $PSItem.Exception.message
32 | } catch [System.Security.SecurityException] {
33 | Write-Warning "A security exception occurred."
34 | Write-Warning $PSItem.Exception.message
35 | } catch [System.UnauthorizedAccessException] {
36 | Write-Warning "Access denied. You do not have permission to perform this operation."
37 | Write-Warning $PSItem.Exception.message
38 | } catch {
39 | # Generic catch block to handle any other type of exception
40 | Write-Warning "Unable to run script for $name due to unhandled exception"
41 | Write-Warning $psitem.Exception.StackTrace
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilShowExt.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilShowExt {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables Show file Extentions
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Show file extentions
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Showing file extentions"
12 | $value = 0
13 | } else {
14 | Write-Host "hiding file extensions"
15 | $value = 1
16 | }
17 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
18 | Set-ItemProperty -Path $Path -Name HideFileExt -Value $value
19 | } catch [System.Security.SecurityException] {
20 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
21 | } catch [System.Management.Automation.ItemNotFoundException] {
22 | Write-Warning $psitem.Exception.ErrorRecord
23 | } catch {
24 | Write-Warning "Unable to set $Name due to unhandled exception"
25 | Write-Warning $psitem.Exception.StackTrace
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilSnapFlyout.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilSnapFlyout {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables Snap Assist Flyout on startup
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Snap Assist Flyout on startup
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Snap Assist Flyout On startup"
12 | $value = 1
13 | } else {
14 | Write-Host "Disabling Snap Assist Flyout On startup"
15 | $value = 0
16 | }
17 |
18 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
19 | taskkill.exe /F /IM "explorer.exe"
20 | Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value
21 | Start-Process "explorer.exe"
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilSnapSuggestion.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilSnapSuggestion {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables Snap Assist Suggestions on startup
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Snap Assist Suggestions on startup
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Snap Assist Suggestion On startup"
12 | $value = 1
13 | } else {
14 | Write-Host "Disabling Snap Assist Suggestion On startup"
15 | $value = 0
16 | }
17 | # taskkill.exe /F /IM "explorer.exe"
18 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
19 | taskkill.exe /F /IM "explorer.exe"
20 | Set-ItemProperty -Path $Path -Name SnapAssist -Value $value
21 | Start-Process "explorer.exe"
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilSnapWindow.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilSnapWindow {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables Snapping Windows on startup
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Snapping Windows on startup
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Snap Windows On startup | Relogin Required"
12 | $value = 1
13 | } else {
14 | Write-Host "Disabling Snap Windows On startup | Relogin Required"
15 | $value = 0
16 | }
17 | $Path = "HKCU:\Control Panel\Desktop"
18 | Set-ItemProperty -Path $Path -Name WindowArrangementActive -Value $value
19 | } catch [System.Security.SecurityException] {
20 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
21 | } catch [System.Management.Automation.ItemNotFoundException] {
22 | Write-Warning $psitem.Exception.ErrorRecord
23 | } catch {
24 | Write-Warning "Unable to set $Name due to unhandled exception"
25 | Write-Warning $psitem.Exception.StackTrace
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilSponsors.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WinUtilSponsors {
2 | <#
3 | .SYNOPSIS
4 | Lists Sponsors from ChrisTitusTech
5 | .DESCRIPTION
6 | Lists Sponsors from ChrisTitusTech
7 | .EXAMPLE
8 | Invoke-WinUtilSponsors
9 | .NOTES
10 | This function is used to list sponsors from ChrisTitusTech
11 | #>
12 | try {
13 | # Define the URL and headers
14 | $url = "https://github.com/sponsors/ChrisTitusTech"
15 | $headers = @{
16 | "User-Agent" = "Chrome/58.0.3029.110"
17 | }
18 |
19 | # Fetch the webpage content
20 | try {
21 | $html = Invoke-RestMethod -Uri $url -Headers $headers
22 | } catch {
23 | Write-Output $_.Exception.Message
24 | exit
25 | }
26 |
27 | # Use regex to extract the content between "Current sponsors" and "Past sponsors"
28 | $currentSponsorsPattern = '(?s)(?<=Current sponsors).*?(?=Past sponsors)'
29 | $currentSponsorsHtml = [regex]::Match($html, $currentSponsorsPattern).Value
30 |
31 | # Use regex to extract the sponsor usernames from the alt attributes in the "Current Sponsors" section
32 | $sponsorPattern = '(?<=alt="@)[^"]+'
33 | $sponsors = [regex]::Matches($currentSponsorsHtml, $sponsorPattern) | ForEach-Object { $_.Value }
34 |
35 | # Exclude "ChrisTitusTech" from the sponsors
36 | $sponsors = $sponsors | Where-Object { $_ -ne "ChrisTitusTech" }
37 |
38 | # Return the sponsors
39 | return $sponsors
40 | } catch {
41 | Write-Error "An error occurred while fetching or processing the sponsors: $_"
42 | return $null
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilStickyKeys.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WinUtilStickyKeys {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables Sticky Keyss on startup
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable Sticky Keys on startup
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Sticky Keys On startup"
12 | $value = 510
13 | } else {
14 | Write-Host "Disabling Sticky Keys On startup"
15 | $value = 58
16 | }
17 | $Path = "HKCU:\Control Panel\Accessibility\StickyKeys"
18 | Set-ItemProperty -Path $Path -Name Flags -Value $value
19 | } catch [System.Security.SecurityException] {
20 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
21 | } catch [System.Management.Automation.ItemNotFoundException] {
22 | Write-Warning $psitem.Exception.ErrorRecord
23 | } catch {
24 | Write-Warning "Unable to set $Name due to unhandled exception"
25 | Write-Warning $psitem.Exception.StackTrace
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilTaskView.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilTaskView {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enable/Disable Task View
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to enable or disable Task View
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Enabling Task View"
15 | $value = 1
16 | } else {
17 | Write-Host "Disabling Task View"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
21 | Set-ItemProperty -Path $Path -Name ShowTaskViewButton -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilTaskbarAlignment.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilTaskbarAlignment {
2 | <#
3 |
4 | .SYNOPSIS
5 | Switches between Center & Left Taskbar Alignment
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to make Taskbar Alignment Center or Left
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Making Taskbar Alignment to the Center"
15 | $value = 1
16 | } else {
17 | Write-Host "Making Taskbar Alignment to the Left"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
21 | Set-ItemProperty -Path $Path -Name "TaskbarAl" -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilTaskbarSearch.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilTaskbarSearch {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enable/Disable Taskbar Search Button.
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to enable or disable Taskbar Search Button.
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Enabling Search Button"
15 | $value = 1
16 | } else {
17 | Write-Host "Disabling Search Button"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search\"
21 | Set-ItemProperty -Path $Path -Name SearchboxTaskbarMode -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilTaskbarWidgets.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilTaskbarWidgets {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enable/Disable Taskbar Widgets
6 |
7 | .PARAMETER Enabled
8 | Indicates whether to enable or disable Taskbar Widgets
9 |
10 | #>
11 | Param($Enabled)
12 | try {
13 | if ($Enabled -eq $false) {
14 | Write-Host "Enabling Taskbar Widgets"
15 | $value = 1
16 | } else {
17 | Write-Host "Disabling Taskbar Widgets"
18 | $value = 0
19 | }
20 | $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
21 | Set-ItemProperty -Path $Path -Name TaskbarDa -Value $value
22 | } catch [System.Security.SecurityException] {
23 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
24 | } catch [System.Management.Automation.ItemNotFoundException] {
25 | Write-Warning $psitem.Exception.ErrorRecord
26 | } catch {
27 | Write-Warning "Unable to set $Name due to unhandled exception"
28 | Write-Warning $psitem.Exception.StackTrace
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Invoke-WinUtilVerboseLogon.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WinUtilVerboseLogon {
2 | <#
3 | .SYNOPSIS
4 | Disables/Enables VerboseLogon Messages
5 | .PARAMETER Enabled
6 | Indicates whether to enable or disable VerboseLogon messages
7 | #>
8 | Param($Enabled)
9 | try {
10 | if ($Enabled -eq $false) {
11 | Write-Host "Enabling Verbose Logon Messages"
12 | $value = 1
13 | } else {
14 | Write-Host "Disabling Verbose Logon Messages"
15 | $value = 0
16 | }
17 | $Path = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System"
18 | Set-ItemProperty -Path $Path -Name VerboseStatus -Value $value
19 | } catch [System.Security.SecurityException] {
20 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
21 | } catch [System.Management.Automation.ItemNotFoundException] {
22 | Write-Warning $psitem.Exception.ErrorRecord
23 | } catch {
24 | Write-Warning "Unable to set $Name due to unhandled exception"
25 | Write-Warning $psitem.Exception.StackTrace
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/functions/private/Remove-WinUtilAPPX.ps1:
--------------------------------------------------------------------------------
1 | function Remove-WinUtilAPPX {
2 | <#
3 |
4 | .SYNOPSIS
5 | Removes all APPX packages that match the given name
6 |
7 | .PARAMETER Name
8 | The name of the APPX package to remove
9 |
10 | .EXAMPLE
11 | Remove-WinUtilAPPX -Name "Microsoft.Microsoft3DViewer"
12 |
13 | #>
14 | param (
15 | $Name
16 | )
17 |
18 | try {
19 | Write-Host "Removing $Name"
20 | Get-AppxPackage "*$Name*" | Remove-AppxPackage -ErrorAction SilentlyContinue
21 | Get-AppxProvisionedPackage -Online | Where-Object DisplayName -like "*$Name*" | Remove-AppxProvisionedPackage -Online -ErrorAction SilentlyContinue
22 | } catch [System.Exception] {
23 | if ($psitem.Exception.Message -like "*The requested operation requires elevation*") {
24 | Write-Warning "Unable to uninstall $name due to a Security Exception"
25 | } else {
26 | Write-Warning "Unable to uninstall $name due to unhandled exception"
27 | Write-Warning $psitem.Exception.StackTrace
28 | }
29 | } catch {
30 | Write-Warning "Unable to uninstall $name due to unhandled exception"
31 | Write-Warning $psitem.Exception.StackTrace
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/functions/private/Set-WinUtilDNS.ps1:
--------------------------------------------------------------------------------
1 | function Set-WinUtilDNS {
2 | <#
3 |
4 | .SYNOPSIS
5 | Sets the DNS of all interfaces that are in the "Up" state. It will lookup the values from the DNS.Json file
6 |
7 | .PARAMETER DNSProvider
8 | The DNS provider to set the DNS server to
9 |
10 | .EXAMPLE
11 | Set-WinUtilDNS -DNSProvider "google"
12 |
13 | #>
14 | param($DNSProvider)
15 | if($DNSProvider -eq "Default") {return}
16 | try {
17 | $Adapters = Get-NetAdapter | Where-Object {$_.Status -eq "Up"}
18 | Write-Host "Ensuring DNS is set to $DNSProvider on the following interfaces"
19 | Write-Host $($Adapters | Out-String)
20 |
21 | Foreach ($Adapter in $Adapters) {
22 | if($DNSProvider -eq "DHCP") {
23 | Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ResetServerAddresses
24 | } else {
25 | Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses ("$($sync.configs.dns.$DNSProvider.Primary)", "$($sync.configs.dns.$DNSProvider.Secondary)")
26 | Set-DnsClientServerAddress -InterfaceIndex $Adapter.ifIndex -ServerAddresses ("$($sync.configs.dns.$DNSProvider.Primary6)", "$($sync.configs.dns.$DNSProvider.Secondary6)")
27 | }
28 | }
29 | } catch {
30 | Write-Warning "Unable to set DNS Provider due to an unhandled exception"
31 | Write-Warning $psitem.Exception.StackTrace
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/functions/private/Set-WinUtilProgressbar.ps1:
--------------------------------------------------------------------------------
1 | function Set-WinUtilProgressbar{
2 | <#
3 | .SYNOPSIS
4 | This function is used to Update the Progress Bar displayed in the winutil GUI.
5 | It will be automatically hidden if the user clicks something and no process is running
6 | .PARAMETER Label
7 | The Text to be overlayed onto the Progress Bar
8 | .PARAMETER PERCENT
9 | The percentage of the Progress Bar that should be filled (0-100)
10 | .PARAMETER Hide
11 | If provided, the Progress Bar and the label will be hidden
12 | #>
13 | param(
14 | [string]$Label,
15 | [ValidateRange(0,100)]
16 | [int]$Percent,
17 | $Hide
18 | )
19 | if ($hide) {
20 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Collapsed"})
21 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Collapsed"})
22 | } else {
23 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Visibility = "Visible"})
24 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBar.Visibility = "Visible"})
25 | }
26 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.Text = $label})
27 | $sync.form.Dispatcher.Invoke([action]{$sync.ProgressBarLabel.Content.ToolTip = $label})
28 | $sync.form.Dispatcher.Invoke([action]{ $sync.ProgressBar.Value = $percent})
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/functions/private/Set-WinUtilRegistry.ps1:
--------------------------------------------------------------------------------
1 | function Set-WinUtilRegistry {
2 | <#
3 |
4 | .SYNOPSIS
5 | Modifies the registry based on the given inputs
6 |
7 | .PARAMETER Name
8 | The name of the key to modify
9 |
10 | .PARAMETER Path
11 | The path to the key
12 |
13 | .PARAMETER Type
14 | The type of value to set the key to
15 |
16 | .PARAMETER Value
17 | The value to set the key to
18 |
19 | .EXAMPLE
20 | Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0"
21 |
22 | #>
23 | param (
24 | $Name,
25 | $Path,
26 | $Type,
27 | $Value
28 | )
29 |
30 | try {
31 | if(!(Test-Path 'HKU:\')) {New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS}
32 |
33 | If (!(Test-Path $Path)) {
34 | Write-Host "$Path was not found, Creating..."
35 | New-Item -Path $Path -Force -ErrorAction Stop | Out-Null
36 | }
37 |
38 | Write-Host "Set $Path\$Name to $Value"
39 | Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null
40 | } catch [System.Security.SecurityException] {
41 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
42 | } catch [System.Management.Automation.ItemNotFoundException] {
43 | Write-Warning $psitem.Exception.ErrorRecord
44 | } catch {
45 | Write-Warning "Unable to set $Name due to unhandled exception"
46 | Write-Warning $psitem.Exception.StackTrace
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/functions/private/Set-WinUtilScheduledTask.ps1:
--------------------------------------------------------------------------------
1 | function Set-WinUtilScheduledTask {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enables/Disables the provided Scheduled Task
6 |
7 | .PARAMETER Name
8 | The path to the Scheduled Task
9 |
10 | .PARAMETER State
11 | The State to set the Task to
12 |
13 | .EXAMPLE
14 | Set-WinUtilScheduledTask -Name "Microsoft\Windows\Application Experience\Microsoft Compatibility Appraiser" -State "Disabled"
15 |
16 | #>
17 | param (
18 | $Name,
19 | $State
20 | )
21 |
22 | try {
23 | if($State -eq "Disabled") {
24 | Write-Host "Disabling Scheduled Task $Name"
25 | Disable-ScheduledTask -TaskName $Name -ErrorAction Stop
26 | }
27 | if($State -eq "Enabled") {
28 | Write-Host "Enabling Scheduled Task $Name"
29 | Enable-ScheduledTask -TaskName $Name -ErrorAction Stop
30 | }
31 | } catch [System.Exception] {
32 | if($psitem.Exception.Message -like "*The system cannot find the file specified*") {
33 | Write-Warning "Scheduled Task $name was not Found"
34 | } else {
35 | Write-Warning "Unable to set $Name due to unhandled exception"
36 | Write-Warning $psitem.Exception.Message
37 | }
38 | } catch {
39 | Write-Warning "Unable to run script for $name due to unhandled exception"
40 | Write-Warning $psitem.Exception.StackTrace
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/functions/private/Set-WinUtilService.ps1:
--------------------------------------------------------------------------------
1 | Function Set-WinUtilService {
2 | <#
3 |
4 | .SYNOPSIS
5 | Changes the startup type of the given service
6 |
7 | .PARAMETER Name
8 | The name of the service to modify
9 |
10 | .PARAMETER StartupType
11 | The startup type to set the service to
12 |
13 | .EXAMPLE
14 | Set-WinUtilService -Name "HomeGroupListener" -StartupType "Manual"
15 |
16 | #>
17 | param (
18 | $Name,
19 | $StartupType
20 | )
21 | try {
22 | Write-Host "Setting Service $Name to $StartupType"
23 |
24 | # Check if the service exists
25 | $service = Get-Service -Name $Name -ErrorAction Stop
26 |
27 | # Service exists, proceed with changing properties
28 | $service | Set-Service -StartupType $StartupType -ErrorAction Stop
29 | } catch [System.ServiceProcess.ServiceNotFoundException] {
30 | Write-Warning "Service $Name was not found"
31 | } catch {
32 | Write-Warning "Unable to set $Name due to unhandled exception"
33 | Write-Warning $_.Exception.Message
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/functions/private/Update-WinUtilProgramWinget.ps1:
--------------------------------------------------------------------------------
1 | Function Update-WinUtilProgramWinget {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | This will update all programs using Winget
7 |
8 | #>
9 |
10 | [ScriptBlock]$wingetinstall = {
11 |
12 | $host.ui.RawUI.WindowTitle = """Winget Install"""
13 |
14 | Start-Transcript "$logdir\winget-update_$dateTime.log" -Append
15 | winget upgrade --all --accept-source-agreements --accept-package-agreements --scope=machine --silent
16 |
17 | }
18 |
19 | $global:WinGetInstall = Start-Process -Verb runas powershell -ArgumentList "-command invoke-command -scriptblock {$wingetinstall} -argumentlist '$($ProgramsToInstall -join ",")'" -PassThru
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/functions/public/Invoke-ScratchDialog.ps1:
--------------------------------------------------------------------------------
1 |
2 | function Invoke-ScratchDialog {
3 |
4 | <#
5 |
6 | .SYNOPSIS
7 | Enable Editable Text box Alternate Scartch path
8 |
9 | .PARAMETER Button
10 | #>
11 | $sync.WPFMicrowinISOScratchDir.IsChecked
12 |
13 |
14 | [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
15 | $Dialog = New-Object System.Windows.Forms.FolderBrowserDialog
16 | $Dialog.SelectedPath = $sync.MicrowinScratchDirBox.Text
17 | $Dialog.ShowDialog()
18 | $filePath = $Dialog.SelectedPath
19 | Write-Host "No ISO is chosen+ $filePath"
20 |
21 | if ([string]::IsNullOrEmpty($filePath)) {
22 | Write-Host "No Folder had chosen"
23 | return
24 | }
25 |
26 | $sync.MicrowinScratchDirBox.Text = Join-Path $filePath "\"
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFCloseButton.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFCloseButton {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Close application
7 |
8 | .PARAMETER Button
9 | #>
10 | $sync["Form"].Close()
11 | Write-Host "Bye bye!"
12 | }
13 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFControlPanel.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFControlPanel {
2 | <#
3 |
4 | .SYNOPSIS
5 | Opens the requested legacy panel
6 |
7 | .PARAMETER Panel
8 | The panel to open
9 |
10 | #>
11 | param($Panel)
12 |
13 | switch ($Panel) {
14 | "WPFPanelcontrol" {cmd /c control}
15 | "WPFPanelnetwork" {cmd /c ncpa.cpl}
16 | "WPFPanelpower" {cmd /c powercfg.cpl}
17 | "WPFPanelregion" {cmd /c intl.cpl}
18 | "WPFPanelsound" {cmd /c mmsys.cpl}
19 | "WPFPanelprinter" {Start-Process "shell:::{A8A91A66-3A7D-4424-8D24-04E180695C7A}"}
20 | "WPFPanelsystem" {cmd /c sysdm.cpl}
21 | "WPFPaneluser" {cmd /c "control userpasswords2"}
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFFeatureInstall.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFFeatureInstall {
2 | <#
3 |
4 | .SYNOPSIS
5 | Installs selected Windows Features
6 |
7 | #>
8 |
9 | if($sync.ProcessRunning) {
10 | $msg = "[Invoke-WPFFeatureInstall] Install process is currently running."
11 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
12 | return
13 | }
14 |
15 | $Features = (Get-WinUtilCheckBoxes)["WPFFeature"]
16 |
17 | Invoke-WPFRunspace -ArgumentList $Features -DebugPreference $DebugPreference -ScriptBlock {
18 | param($Features, $DebugPreference)
19 | $sync.ProcessRunning = $true
20 | if ($Features.count -eq 1) {
21 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
22 | } else {
23 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
24 | }
25 |
26 | Invoke-WinUtilFeatureInstall $Features
27 |
28 | $sync.ProcessRunning = $false
29 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
30 |
31 | Write-Host "==================================="
32 | Write-Host "--- Features are Installed ---"
33 | Write-Host "--- A Reboot may be required ---"
34 | Write-Host "==================================="
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFFixesNetwork.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFFixesNetwork {
2 | <#
3 |
4 | .SYNOPSIS
5 | Resets various network configurations
6 |
7 | #>
8 |
9 | Write-Host "Resetting Network with netsh"
10 |
11 | # Reset WinSock catalog to a clean state
12 | Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winsock", "reset"
13 | # Resets WinHTTP proxy setting to DIRECT
14 | Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "winhttp", "reset", "proxy"
15 | # Removes all user configured IP settings
16 | Start-Process -NoNewWindow -FilePath "netsh" -ArgumentList "int", "ip", "reset"
17 |
18 | Write-Host "Process complete. Please reboot your computer."
19 |
20 | $ButtonType = [System.Windows.MessageBoxButton]::OK
21 | $MessageboxTitle = "Network Reset "
22 | $Messageboxbody = ("Stock settings loaded.`n Please reboot your computer")
23 | $MessageIcon = [System.Windows.MessageBoxImage]::Information
24 |
25 | [System.Windows.MessageBox]::Show($Messageboxbody, $MessageboxTitle, $ButtonType, $MessageIcon)
26 | Write-Host "=========================================="
27 | Write-Host "-- Network Configuration has been Reset --"
28 | Write-Host "=========================================="
29 | }
30 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFFixesWinget.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFFixesWinget {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Fixes Winget by running choco install winget
7 | .DESCRIPTION
8 | BravoNorris for the fantastic idea of a button to reinstall winget
9 | #>
10 | # Install Choco if not already present
11 | Install-WinUtilChoco
12 | Start-Process -FilePath "choco" -ArgumentList "install winget -y --force" -NoNewWindow -Wait
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFFormVariables.ps1:
--------------------------------------------------------------------------------
1 | Function Invoke-WPFFormVariables {
2 | <#
3 |
4 | .SYNOPSIS
5 | Prints the logo
6 |
7 | #>
8 | #If ($global:ReadmeDisplay -ne $true) { Write-Host "If you need to reference this display again, run Get-FormVariables" -ForegroundColor Yellow; $global:ReadmeDisplay = $true }
9 |
10 |
11 | Write-Host ""
12 | Write-Host " CCCCCCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT "
13 | Write-Host " CCC::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T "
14 | Write-Host "CC:::::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T "
15 | Write-Host "C:::::CCCCCCCC::::CT:::::TT:::::::TT:::::TT:::::TT:::::::TT:::::T "
16 | Write-Host "C:::::C CCCCCCTTTTTT T:::::T TTTTTTTTTTTT T:::::T TTTTTT"
17 | Write-Host "C:::::C T:::::T T:::::T "
18 | Write-Host "C:::::C T:::::T T:::::T "
19 | Write-Host "C:::::C T:::::T T:::::T "
20 | Write-Host "C:::::C T:::::T T:::::T "
21 | Write-Host "C:::::C T:::::T T:::::T "
22 | Write-Host "C:::::C T:::::T T:::::T "
23 | Write-Host "C:::::C CCCCCC T:::::T T:::::T "
24 | Write-Host "C:::::CCCCCCCC::::C TT:::::::TT TT:::::::TT "
25 | Write-Host "CC:::::::::::::::C T:::::::::T T:::::::::T "
26 | Write-Host "CCC::::::::::::C T:::::::::T T:::::::::T "
27 | Write-Host " CCCCCCCCCCCCC TTTTTTTTTTT TTTTTTTTTTT "
28 | Write-Host ""
29 | Write-Host "====Chris Titus Tech====="
30 | Write-Host "=====Windows Toolbox====="
31 |
32 | #====DEBUG GUI Elements====
33 |
34 | #Write-Host "Found the following interactable elements from our form" -ForegroundColor Cyan
35 | #get-variable WPF*
36 | }
37 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFGetInstalled.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFGetInstalled {
2 | <#
3 | TODO: Add the Option to use Chocolatey as Engine
4 | .SYNOPSIS
5 | Invokes the function that gets the checkboxes to check in a new runspace
6 |
7 | .PARAMETER checkbox
8 | Indicates whether to check for installed 'winget' programs or applied 'tweaks'
9 |
10 | #>
11 | param($checkbox)
12 |
13 | if($sync.ProcessRunning) {
14 | $msg = "[Invoke-WPFGetInstalled] Install process is currently running."
15 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
16 | return
17 | }
18 |
19 | if(($sync.WPFpreferChocolatey.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
20 | return
21 | }
22 | $preferChoco = $sync.WPFpreferChocolatey.IsChecked
23 | Invoke-WPFRunspace -ArgumentList $checkbox, $preferChoco -DebugPreference $DebugPreference -ScriptBlock {
24 | param($checkbox, $preferChoco, $DebugPreference)
25 |
26 | $sync.ProcessRunning = $true
27 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" })
28 |
29 | if($checkbox -eq "winget") {
30 | Write-Host "Getting Installed Programs..."
31 | }
32 | if($checkbox -eq "tweaks") {
33 | Write-Host "Getting Installed Tweaks..."
34 | }
35 | if ($preferChoco -and $checkbox -eq "winget") {
36 | $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox "choco"
37 | }
38 | else{
39 | $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
40 | }
41 |
42 | $sync.form.Dispatcher.invoke({
43 | foreach($checkbox in $Checkboxes) {
44 | $sync.$checkbox.ischecked = $True
45 | }
46 | })
47 |
48 | Write-Host "Done..."
49 | $sync.ProcessRunning = $false
50 | $sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "None" })
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFImpex.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFImpex {
2 | <#
3 |
4 | .SYNOPSIS
5 | Handles importing and exporting of the checkboxes checked for the tweaks section
6 |
7 | .PARAMETER type
8 | Indicates whether to 'import' or 'export'
9 |
10 | .PARAMETER checkbox
11 | The checkbox to export to a file or apply the imported file to
12 |
13 | .EXAMPLE
14 | Invoke-WPFImpex -type "export"
15 |
16 | #>
17 | param(
18 | $type,
19 | $Config = $null
20 | )
21 |
22 | if ($type -eq "export") {
23 | $FileBrowser = New-Object System.Windows.Forms.SaveFileDialog
24 | }
25 | if ($type -eq "import") {
26 | $FileBrowser = New-Object System.Windows.Forms.OpenFileDialog
27 | }
28 |
29 | if (-not $Config) {
30 | $FileBrowser.InitialDirectory = [Environment]::GetFolderPath('Desktop')
31 | $FileBrowser.Filter = "JSON Files (*.json)|*.json"
32 | $FileBrowser.ShowDialog() | Out-Null
33 |
34 | if($FileBrowser.FileName -eq "") {
35 | return
36 | } else {
37 | $Config = $FileBrowser.FileName
38 | }
39 | }
40 |
41 | if ($type -eq "export") {
42 | $jsonFile = Get-WinUtilCheckBoxes -unCheck $false
43 | $jsonFile | ConvertTo-Json | Out-File $FileBrowser.FileName -Force
44 | $runscript = "iex ""& { `$(irm christitus.com/win) } -Config '$($FileBrowser.FileName)'"""
45 | $runscript | Set-Clipboard
46 | }
47 | if ($type -eq "import") {
48 | $jsonFile = Get-Content $Config | ConvertFrom-Json
49 |
50 | $flattenedJson = @()
51 | $jsonFile.PSObject.Properties | ForEach-Object {
52 | $category = $_.Name
53 | foreach ($checkboxName in $_.Value) {
54 | if ($category -ne "Install") {
55 | $flattenedJson += $checkboxName
56 | }
57 | }
58 | }
59 |
60 | $flattenedJson = [string]$flattenedJson
61 | Invoke-WPFPresets -preset $flattenedJson -imported $true
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFInstallUpgrade.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFInstallUpgrade {
2 | <#
3 |
4 | .SYNOPSIS
5 | Invokes the function that upgrades all installed programs
6 |
7 | #>
8 | if ($sync.WPFpreferChocolatey.IsChecked) {
9 | Install-WinUtilChoco
10 | $chocoUpgradeStatus = (Start-Process "choco" -ArgumentList "upgrade all -y" -Wait -PassThru -NoNewWindow).ExitCode
11 | if ($chocoUpgradeStatus -eq 0) {
12 | Write-Host "Upgrade Successful"
13 | }
14 | else{
15 | Write-Host "Error Occured. Return Code: $chocoUpgradeStatus"
16 | }
17 | }
18 | else{
19 | if((Test-WinUtilPackageManager -winget) -eq "not-installed") {
20 | return
21 | }
22 |
23 | if(Get-WinUtilInstallerProcess -Process $global:WinGetInstall) {
24 | $msg = "[Invoke-WPFInstallUpgrade] Install process is currently running. Please check for a powershell window labeled 'Winget Install'"
25 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
26 | return
27 | }
28 |
29 | Update-WinUtilProgramWinget
30 |
31 | Write-Host "==========================================="
32 | Write-Host "-- Updates started ---"
33 | Write-Host "-- You can close this window if desired ---"
34 | Write-Host "==========================================="
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFOOSU.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFOOSU {
2 | <#
3 | .SYNOPSIS
4 | Downloads and runs OO Shutup 10
5 | #>
6 | try {
7 | $OOSU_filepath = "$ENV:temp\OOSU10.exe"
8 | $Initial_ProgressPreference = $ProgressPreference
9 | $ProgressPreference = "SilentlyContinue" # Disables the Progress Bar to drasticly speed up Invoke-WebRequest
10 | Invoke-WebRequest -Uri "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -OutFile $OOSU_filepath
11 | Write-Host "Starting OO Shutup 10 ..."
12 | Start-Process $OOSU_filepath
13 | } catch {
14 | Write-Host "Error Downloading and Running OO Shutup 10" -ForegroundColor Red
15 | }
16 | finally {
17 | $ProgressPreference = $Initial_ProgressPreference
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFPanelAutologin.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFPanelAutologin {
2 | <#
3 |
4 | .SYNOPSIS
5 | Enables autologin using Sysinternals Autologon.exe
6 |
7 | #>
8 |
9 | # Official Microsoft recommendation: https://learn.microsoft.com/en-us/sysinternals/downloads/autologon
10 | Invoke-WebRequest -Uri "https://live.sysinternals.com/Autologon.exe" -OutFile "$env:temp\autologin.exe"
11 | cmd /c "$env:temp\autologin.exe" /accepteula
12 | }
13 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFPanelDISM.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFPanelDISM {
2 | <#
3 |
4 | .SYNOPSIS
5 | Checks for system corruption using Chkdsk, SFC, and DISM
6 |
7 | .DESCRIPTION
8 | 1. Chkdsk - Fixes disk and filesystem corruption
9 | 2. SFC Run 1 - Fixes system file corruption, and fixes DISM if it was corrupted
10 | 3. DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted
11 | 4. SFC Run 2 - Fixes system file corruption, this time with an almost guaranteed uncorrupted system image
12 |
13 | .NOTES
14 | Command Arguments:
15 | 1. Chkdsk
16 | /Scan - Runs an online scan on the system drive, attempts to fix any corruption, and queues other corruption for fixing on reboot
17 | 2. SFC
18 | /ScanNow - Performs a scan of the system files and fixes any corruption
19 | 3. DISM - Fixes system image corruption, and fixes SFC's system image if it was corrupted
20 | /Online - Fixes the currently running system image
21 | /Cleanup-Image - Performs cleanup operations on the image, could remove some unneeded temporary files
22 | /Restorehealth - Performs a scan of the image and fixes any corruption
23 |
24 | #>
25 | Start-Process PowerShell -ArgumentList "Write-Host '(1/4) Chkdsk' -ForegroundColor Green; Chkdsk /scan;
26 | Write-Host '`n(2/4) SFC - 1st scan' -ForegroundColor Green; sfc /scannow;
27 | Write-Host '`n(3/4) DISM' -ForegroundColor Green; DISM /Online /Cleanup-Image /Restorehealth;
28 | Write-Host '`n(4/4) SFC - 2nd scan' -ForegroundColor Green; sfc /scannow;
29 | Read-Host '`nPress Enter to Continue'" -verb runas
30 | }
31 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFPresets.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFPresets {
2 | <#
3 |
4 | .SYNOPSIS
5 | Sets the options in the tweaks panel to the given preset
6 |
7 | .PARAMETER preset
8 | The preset to set the options to
9 |
10 | .PARAMETER imported
11 | If the preset is imported from a file, defaults to false
12 |
13 | .PARAMETER checkboxfilterpattern
14 | The Pattern to use when filtering through CheckBoxes, defaults to "**"
15 |
16 | #>
17 |
18 | param (
19 | [Parameter(position=0)]
20 | [string]$preset = "",
21 |
22 | [Parameter(position=1)]
23 | [bool]$imported = $false,
24 |
25 | [Parameter(position=2)]
26 | [string]$checkboxfilterpattern = "**"
27 | )
28 |
29 | if ($imported -eq $true) {
30 | $CheckBoxesToCheck = $preset
31 | } else {
32 | $CheckBoxesToCheck = $sync.configs.preset.$preset
33 | }
34 |
35 | $CheckBoxes = ($sync.GetEnumerator()).where{ $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" -and $_.Name -like "$checkboxfilterpattern"}
36 | Write-Debug "Getting checkboxes to set, number of checkboxes: $($CheckBoxes.Count)"
37 |
38 | if ($CheckBoxesToCheck -ne "") {
39 | $debugMsg = "CheckBoxes to Check are: "
40 | $CheckBoxesToCheck | ForEach-Object { $debugMsg += "$_, " }
41 | $debugMsg = $debugMsg -replace (',\s*$', '')
42 | Write-Debug "$debugMsg"
43 | }
44 |
45 | foreach ($CheckBox in $CheckBoxes) {
46 | $checkboxName = $CheckBox.Key
47 |
48 | if (-not $CheckBoxesToCheck) {
49 | $sync.$checkboxName.IsChecked = $false
50 | continue
51 | }
52 |
53 | # Check if the checkbox name exists in the flattened JSON hashtable
54 | if ($CheckBoxesToCheck.Contains($checkboxName)) {
55 | # If it exists, set IsChecked to true
56 | $sync.$checkboxName.IsChecked = $true
57 | Write-Debug "$checkboxName is checked"
58 | } else {
59 | # If it doesn't exist, set IsChecked to false
60 | $sync.$checkboxName.IsChecked = $false
61 | Write-Debug "$checkboxName is not checked"
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFRunAdobeCCCleanerTool.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFRunAdobeCCCleanerTool {
2 | <#
3 | .SYNOPSIS
4 | It removes or fixes problem files and resolves permission issues in registry keys.
5 | .DESCRIPTION
6 | The Creative Cloud Cleaner tool is a utility for experienced users to clean up corrupted installations.
7 | #>
8 |
9 | [string]$url="https://swupmf.adobe.com/webfeed/CleanerTool/win/AdobeCreativeCloudCleanerTool.exe"
10 |
11 | Write-Host "The Adobe Creative Cloud Cleaner tool is hosted at"
12 | Write-Host "$url"
13 |
14 | try {
15 | # Don't show the progress because it will slow down the download speed
16 | $ProgressPreference='SilentlyContinue'
17 |
18 | Invoke-WebRequest -Uri $url -OutFile "$env:TEMP\AdobeCreativeCloudCleanerTool.exe" -UseBasicParsing -ErrorAction SilentlyContinue -Verbose
19 |
20 | # Revert back the ProgressPreference variable to the default value since we got the file desired
21 | $ProgressPreference='Continue'
22 |
23 | Start-Process -FilePath "$env:TEMP\AdobeCreativeCloudCleanerTool.exe" -Wait -ErrorAction SilentlyContinue -Verbose
24 | } catch {
25 | Write-Error $_.Exception.Message
26 | } finally {
27 | if (Test-Path -Path "$env:TEMP\AdobeCreativeCloudCleanerTool.exe") {
28 | Write-Host "Cleaning up..."
29 | Remove-Item -Path "$env:TEMP\AdobeCreativeCloudCleanerTool.exe" -Verbose
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFRunspace.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFRunspace {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Creates and invokes a runspace using the given scriptblock and argumentlist
7 |
8 | .PARAMETER ScriptBlock
9 | The scriptblock to invoke in the runspace
10 |
11 | .PARAMETER ArgumentList
12 | A list of arguments to pass to the runspace
13 |
14 | .PARAMETER ParameterList
15 | A list of named parameters that should be provided.
16 | .EXAMPLE
17 | Invoke-WPFRunspace `
18 | -ScriptBlock $sync.ScriptsInstallPrograms `
19 | -ArgumentList "Installadvancedip,Installbitwarden" `
20 |
21 | Invoke-WPFRunspace`
22 | -ScriptBlock $sync.ScriptsInstallPrograms `
23 | -ParameterList @(("PackagesToInstall", @("Installadvancedip,Installbitwarden")),("ChocoPreference", $true))
24 | #>
25 |
26 | [CmdletBinding()]
27 | Param (
28 | $ScriptBlock,
29 | $ArgumentList,
30 | $ParameterList,
31 | $DebugPreference
32 | )
33 |
34 | # Create a PowerShell instance
35 | $script:powershell = [powershell]::Create()
36 |
37 | # Add Scriptblock and Arguments to runspace
38 | $script:powershell.AddScript($ScriptBlock)
39 | $script:powershell.AddArgument($ArgumentList)
40 |
41 | foreach ($parameter in $ParameterList) {
42 | $script:powershell.AddParameter($parameter[0], $parameter[1])
43 | }
44 | $script:powershell.AddArgument($DebugPreference) # Pass DebugPreference to the script block
45 | $script:powershell.RunspacePool = $sync.runspace
46 |
47 | # Execute the RunspacePool
48 | $script:handle = $script:powershell.BeginInvoke()
49 |
50 | # Clean up the RunspacePool threads when they are complete, and invoke the garbage collector to clean up the memory
51 | if ($script:handle.IsCompleted) {
52 | $script:powershell.EndInvoke($script:handle)
53 | $script:powershell.Dispose()
54 | $sync.runspace.Dispose()
55 | $sync.runspace.Close()
56 | [System.GC]::Collect()
57 | }
58 | # Return the handle
59 | return $handle
60 | }
61 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFTab.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFTab {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Sets the selected tab to the tab that was clicked
7 |
8 | .PARAMETER ClickedTab
9 | The name of the tab that was clicked
10 |
11 | #>
12 |
13 | Param ($ClickedTab)
14 |
15 | $tabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"}
16 | $tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1
17 |
18 | $filter = Get-WinUtilVariables -Type ToggleButton | Where-Object {$psitem -like "WPFTab?BT"}
19 | $sync.GetEnumerator() | Where-Object {$psitem.Key -in $filter} | ForEach-Object {
20 | if ($ClickedTab -ne $PSItem.name) {
21 | $sync[$PSItem.Name].IsChecked = $false
22 | # $tabNumber = [int]($PSItem.Name -replace "WPFTab","" -replace "BT","") - 1
23 | # $sync.$tabNav.Items[$tabNumber].IsSelected = $false
24 | } else {
25 | $sync["$ClickedTab"].IsChecked = $true
26 | $tabNumber = [int]($ClickedTab-replace "WPFTab","" -replace "BT","") - 1
27 | $sync.$tabNav.Items[$tabNumber].IsSelected = $true
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFToggle.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFToggle {
2 |
3 | <#
4 |
5 | .SYNOPSIS
6 | Invokes the scriptblock for the given toggle
7 |
8 | .PARAMETER Button
9 | The name of the toggle to invoke
10 |
11 | #>
12 |
13 | Param ([string]$Button)
14 |
15 | # Use this to get the name of the button
16 | #[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
17 |
18 | $ToggleStatus = (Get-WinUtilToggleStatus $Button)
19 |
20 | Switch -Wildcard ($Button) {
21 |
22 | "WPFToggleDarkMode" {Invoke-WinUtilDarkMode $ToggleStatus}
23 | "WPFToggleBingSearch" {Invoke-WinUtilBingSearch $ToggleStatus}
24 | "WPFToggleNumLock" {Invoke-WinUtilNumLock $ToggleStatus}
25 | "WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $ToggleStatus}
26 | "WPFToggleShowExt" {Invoke-WinUtilShowExt $ToggleStatus}
27 | "WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $ToggleStatus}
28 | "WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $ToggleStatus}
29 | "WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $ToggleStatus}
30 | "WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $ToggleStatus}
31 | "WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $ToggleStatus}
32 | "WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $ToggleStatus}
33 | "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $ToggleStatus}
34 | "WPFToggleTaskView" {Invoke-WinUtilTaskView $ToggleStatus}
35 | "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $ToggleStatus}
36 | "WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $ToggleStatus}
37 | "WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $ToggleStatus}
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFUpdatesdisable.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFUpdatesdisable {
2 | <#
3 |
4 | .SYNOPSIS
5 | Disables Windows Update
6 |
7 | .NOTES
8 | Disabling Windows Update is not recommended. This is only for advanced users who know what they are doing.
9 |
10 | #>
11 | If (!(Test-Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU")) {
12 | New-Item -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Force | Out-Null
13 | }
14 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "NoAutoUpdate" -Type DWord -Value 1
15 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate\AU" -Name "AUOptions" -Type DWord -Value 1
16 | If (!(Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config")) {
17 | New-Item -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Force | Out-Null
18 | }
19 | Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\DeliveryOptimization\Config" -Name "DODownloadMode" -Type DWord -Value 0
20 |
21 | $services = @(
22 | "BITS"
23 | "wuauserv"
24 | )
25 |
26 | foreach ($service in $services) {
27 | # -ErrorAction SilentlyContinue is so it doesn't write an error to stdout if a service doesn't exist
28 |
29 | Write-Host "Setting $service StartupType to Disabled"
30 | Get-Service -Name $service -ErrorAction SilentlyContinue | Set-Service -StartupType Disabled
31 | }
32 | Write-Host "================================="
33 | Write-Host "--- Updates ARE DISABLED ---"
34 | Write-Host "================================="
35 | }
36 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFundoall.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFundoall {
2 | <#
3 |
4 | .SYNOPSIS
5 | Undoes every selected tweak
6 |
7 | #>
8 |
9 | if($sync.ProcessRunning) {
10 | $msg = "[Invoke-WPFundoall] Install process is currently running."
11 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
12 | return
13 | }
14 |
15 | $tweaks = (Get-WinUtilCheckBoxes)["WPFtweaks"]
16 |
17 | if ($tweaks.count -eq 0) {
18 | $msg = "Please check the tweaks you wish to undo."
19 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
20 | return
21 | }
22 |
23 | Invoke-WPFRunspace -ArgumentList $tweaks -DebugPreference $DebugPreference -ScriptBlock {
24 | param($tweaks, $DebugPreference)
25 |
26 | $sync.ProcessRunning = $true
27 | if ($tweaks.count -eq 1) {
28 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Indeterminate" -value 0.01 -overlay "logo" })
29 | } else {
30 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "Normal" -value 0.01 -overlay "logo" })
31 | }
32 |
33 |
34 | for ($i = 0; $i -lt $tweaks.Count; $i++) {
35 | Set-WinUtilProgressBar -Label "Undoing $($tweaks[$i])" -Percent ($i / $tweaks.Count * 100)
36 | Invoke-WinUtiltweaks $tweaks[$i] -undo $true
37 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -value ($i/$tweaks.Count) })
38 | }
39 |
40 | Set-WinUtilProgressBar -Label "Undo Tweaks Finished" -Percent 100
41 | $sync.ProcessRunning = $false
42 | $sync.form.Dispatcher.Invoke([action]{ Set-WinUtilTaskbaritem -state "None" -overlay "checkmark" })
43 | Write-Host "=================================="
44 | Write-Host "--- Undo Tweaks are Finished ---"
45 | Write-Host "=================================="
46 |
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/lint/PSScriptAnalyser.ps1:
--------------------------------------------------------------------------------
1 | @{
2 | # Only diagnostic records of the specified severity will be generated.
3 | # Uncomment the following line if you only want Errors and Warnings but
4 | # not Information diagnostic records.
5 | # Severity = @('Error','Warning')
6 |
7 | # Analyze **only** the following rules. Use IncludeRules when you want
8 | # to invoke only a small subset of the default rules.
9 | <#
10 | IncludeRules = @('PSAvoidDefaultValueSwitchParameter',
11 | 'PSMisleadingBacktick',
12 | 'PSMissingModuleManifestField',
13 | 'PSReservedCmdletChar',
14 | 'PSReservedParams',
15 | 'PSShouldProcess',
16 | 'PSUseApprovedVerbs',
17 | 'PSUseDeclaredVarsMoreThanAssignments')
18 | #>
19 | # Do not analyze the following rules. Use ExcludeRules when you have
20 | # commented out the IncludeRules settings above and want to include all
21 | # the default rules except for those you exclude below.
22 | # Note: if a rule is in both IncludeRules and ExcludeRules, the rule
23 | # will be excluded.
24 | ExcludeRules = @('PSAvoidUsingWriteHost')
25 | }
26 |
--------------------------------------------------------------------------------
/overrides/main.html:
--------------------------------------------------------------------------------
1 | {% extends "base.html" %}
2 |
3 | {% block header %}
4 | {{ super() }}
5 |
6 | Announcement: We are currently not adding any applications to WinUtil and any apps that will be added through a PR will be declined by the maintainer.
7 |
8 | {% endblock %}
9 |
10 | {% block footer %}
11 | {# Empty block to override the footer #}
12 | {% endblock %}
13 |
--------------------------------------------------------------------------------
/releases/oscdimg.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/CodingWonders/winutil/81aead7a687feae2c4ffb9841196559692789eba/releases/oscdimg.exe
--------------------------------------------------------------------------------