") {
39 | Write-Host "Set $Path\$Name to $Value"
40 | Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value -Force -ErrorAction Stop | Out-Null
41 | }
42 | else{
43 | Write-Host "Remove $Path\$Name"
44 | Remove-ItemProperty -Path $Path -Name $Name -Force -ErrorAction Stop | Out-Null
45 | }
46 | } catch [System.Security.SecurityException] {
47 | Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
48 | } catch [System.Management.Automation.ItemNotFoundException] {
49 | Write-Warning $psitem.Exception.ErrorRecord
50 | } catch [System.UnauthorizedAccessException] {
51 | Write-Warning $psitem.Exception.Message
52 | } catch {
53 | Write-Warning "Unable to set $Name due to unhandled exception"
54 | Write-Warning $psitem.Exception.StackTrace
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/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 | "WPFPanelGodMode" {Start-Process "shell:::{ED7BA470-8E54-465E-825C-99712043E01C}"}
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/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-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 | if ($sync.ProcessRunning) {
13 | $msg = "[Invoke-WPFGetInstalled] Install process is currently running."
14 | [System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Warning)
15 | return
16 | }
17 |
18 | if (($sync.ChocoRadioButton.IsChecked -eq $false) -and ((Test-WinUtilPackageManager -winget) -eq "not-installed") -and $checkbox -eq "winget") {
19 | return
20 | }
21 | $managerPreference = $sync["ManagerPreference"]
22 |
23 | Invoke-WPFRunspace -ParameterList @(("managerPreference", $managerPreference),("checkbox", $checkbox)) -DebugPreference $DebugPreference -ScriptBlock {
24 | param (
25 | [string]$checkbox,
26 | [PackageManagers]$managerPreference
27 | )
28 | $sync.ProcessRunning = $true
29 | $sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "Indeterminate" })
30 |
31 | if ($checkbox -eq "winget") {
32 | Write-Host "Getting Installed Programs..."
33 | switch ($managerPreference) {
34 | "Choco"{$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox "choco"; break}
35 | "Winget"{$Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox; break}
36 | }
37 | }
38 | elseif ($checkbox -eq "tweaks") {
39 | Write-Host "Getting Installed Tweaks..."
40 | $Checkboxes = Invoke-WinUtilCurrentSystem -CheckBox $checkbox
41 | }
42 |
43 | $sync.form.Dispatcher.invoke({
44 | foreach ($checkbox in $Checkboxes) {
45 | $sync.$checkbox.ischecked = $True
46 | }
47 | })
48 |
49 | Write-Host "Done..."
50 | $sync.ProcessRunning = $false
51 | $sync.form.Dispatcher.Invoke([action] { Set-WinUtilTaskbaritem -state "None" })
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/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.ChocoRadioButton.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-WPFPopup.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFPopup {
2 | param (
3 | [ValidateSet("Show", "Hide", "Toggle")]
4 | [string]$Action = "",
5 |
6 | [string[]]$Popups = @(),
7 |
8 | [ValidateScript({
9 | $invalid = $_.GetEnumerator() | Where-Object { $_.Value -notin @("Show", "Hide", "Toggle") }
10 | if ($invalid) {
11 | throw "Found invalid Popup-Action pair(s): " + ($invalid | ForEach-Object { "$($_.Key) = $($_.Value)" } -join "; ")
12 | }
13 | $true
14 | })]
15 | [hashtable]$PopupActionTable = @{}
16 | )
17 |
18 | if (-not $PopupActionTable.Count -and (-not $Action -or -not $Popups.Count)) {
19 | throw "Provide either 'PopupActionTable' or both 'Action' and 'Popups'."
20 | }
21 |
22 | if ($PopupActionTable.Count -and ($Action -or $Popups.Count)) {
23 | throw "Use 'PopupActionTable' on its own, or 'Action' with 'Popups'."
24 | }
25 |
26 | # Collect popups and actions
27 | $PopupsToProcess = if ($PopupActionTable.Count) {
28 | $PopupActionTable.GetEnumerator() | ForEach-Object { [PSCustomObject]@{ Name = "$($_.Key)Popup"; Action = $_.Value } }
29 | } else {
30 | $Popups | ForEach-Object { [PSCustomObject]@{ Name = "$_`Popup"; Action = $Action } }
31 | }
32 |
33 | $PopupsNotFound = @()
34 |
35 | # Apply actions
36 | foreach ($popupEntry in $PopupsToProcess) {
37 | $popupName = $popupEntry.Name
38 |
39 | if (-not $sync.$popupName) {
40 | $PopupsNotFound += $popupName
41 | continue
42 | }
43 |
44 | $sync.$popupName.IsOpen = switch ($popupEntry.Action) {
45 | "Show" { $true }
46 | "Hide" { $false }
47 | "Toggle" { -not $sync.$popupName.IsOpen }
48 | }
49 | }
50 |
51 | if ($PopupsNotFound.Count -gt 0) {
52 | throw "Could not find the following popups: $($PopupsNotFound -join ', ')"
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/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 | [Array]$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-WPFSSHServer.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFSSHServer {
2 | <#
3 |
4 | .SYNOPSIS
5 | Invokes the OpenSSH Server install in a runspace
6 |
7 | #>
8 |
9 | Invoke-WPFRunspace -DebugPreference $DebugPreference -ScriptBlock {
10 |
11 | Invoke-WinUtilSSHServer
12 |
13 | Write-Host "======================================="
14 | Write-Host "-- OpenSSH Server installed! ---"
15 | Write-Host "======================================="
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/functions/public/Invoke-WPFSelectedAppsUpdate.ps1:
--------------------------------------------------------------------------------
1 | function Invoke-WPFSelectedAppsUpdate {
2 | <#
3 | .SYNOPSIS
4 | This is a helper function that is called by the Checked and Unchecked events of the Checkboxes on the install tab.
5 | It Updates the "Selected Apps" selectedAppLabel on the Install Tab to represent the current collection
6 | .PARAMETER type
7 | Eigther: Add | Remove
8 | .PARAMETER checkbox
9 | should contain the current instance of the checkbox that triggered the Event.
10 | Most of the time will be the automatic variable $this
11 | .EXAMPLE
12 | $checkbox.Add_Unchecked({Invoke-WPFSelectedAppsUpdate -type "Remove" -checkbox $this})
13 | OR
14 | Invoke-WPFSelectedAppsUpdate -type "Add" -checkbox $specificCheckbox
15 | #>
16 | param (
17 | $type,
18 | $checkbox
19 | )
20 |
21 | $selectedAppsButton = $sync.WPFselectedAppsButton
22 | # Get the actual Name from the selectedAppLabel inside the Checkbox
23 | $appKey = $checkbox.Parent.Tag
24 | if ($type -eq "Add") {
25 | $sync.selectedApps.Add($appKey)
26 | # The List type needs to be specified again, because otherwise Sort-Object will convert the list to a string if there is only a single entry
27 | [System.Collections.Generic.List[pscustomobject]]$sync.selectedApps = $sync.SelectedApps | Sort-Object
28 |
29 | }
30 | elseif ($type -eq "Remove") {
31 | $sync.SelectedApps.Remove($appKey)
32 | }
33 | else{
34 | Write-Error "Type: $type not implemented"
35 | }
36 |
37 | $count = $sync.SelectedApps.Count
38 | $selectedAppsButton.Content = "Selected Apps: $count"
39 | # On every change, remove all entries inside the Popup Menu. This is done, so we can keep the alphabetical order even if elements are selected in a random way
40 | $sync.selectedAppsstackPanel.Children.Clear()
41 | $sync.SelectedApps | Foreach-Object { Add-SelectedAppsMenuItem -name $($sync.configs.applicationsHashtable.$_.Content) -key $_ }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/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 (
14 | [Parameter(Mandatory,position=0)]
15 | [string]$ClickedTab
16 | )
17 |
18 | $tabNav = Get-WinUtilVariables | Where-Object {$psitem -like "WPFTabNav"}
19 | $tabNumber = [int]($ClickedTab -replace "WPFTab","" -replace "BT","") - 1
20 |
21 | $filter = Get-WinUtilVariables -Type ToggleButton | Where-Object {$psitem -like "WPFTab?BT"}
22 | ($sync.GetEnumerator()).where{$psitem.Key -in $filter} | ForEach-Object {
23 | if ($ClickedTab -ne $PSItem.name) {
24 | $sync[$PSItem.Name].IsChecked = $false
25 | } else {
26 | $sync["$ClickedTab"].IsChecked = $true
27 | $tabNumber = [int]($ClickedTab-replace "WPFTab","" -replace "BT","") - 1
28 | $sync.$tabNav.Items[$tabNumber].IsSelected = $true
29 | }
30 | }
31 | $sync.currentTab = $sync.$tabNav.Items[$tabNumber].Header
32 |
33 | # Always reset the filter for the current tab
34 | if ($sync.currentTab -eq "Install") {
35 | # Reset Install tab filter
36 | Find-AppsByNameOrDescription -SearchString ""
37 | } elseif ($sync.currentTab -eq "Tweaks") {
38 | # Reset Tweaks tab filter
39 | Find-TweaksByNameOrDescription -SearchString ""
40 | }
41 |
42 | # Show search bar in Install and Tweaks tabs
43 | if ($tabNumber -eq 0 -or $tabNumber -eq 1) {
44 | $sync.SearchBar.Visibility = "Visible"
45 | $searchIcon = ($sync.Form.FindName("SearchBar").Parent.Children | Where-Object { $_ -is [System.Windows.Controls.TextBlock] -and $_.Text -eq [char]0xE721 })[0]
46 | if ($searchIcon) {
47 | $searchIcon.Visibility = "Visible"
48 | }
49 | } else {
50 | $sync.SearchBar.Visibility = "Collapsed"
51 | $searchIcon = ($sync.Form.FindName("SearchBar").Parent.Children | Where-Object { $_ -is [System.Windows.Controls.TextBlock] -and $_.Text -eq [char]0xE721 })[0]
52 | if ($searchIcon) {
53 | $searchIcon.Visibility = "Collapsed"
54 | }
55 | # Hide the clear button if it's visible
56 | $sync.SearchBarClearButton.Visibility = "Collapsed"
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/functions/public/Show-CTTLogo.ps1:
--------------------------------------------------------------------------------
1 | Function Show-CTTLogo {
2 | <#
3 | .SYNOPSIS
4 | Displays the CTT logo in ASCII art.
5 | .DESCRIPTION
6 | This function displays the CTT logo in ASCII art format.
7 | .PARAMETER None
8 | No parameters are required for this function.
9 | .EXAMPLE
10 | Show-CTTLogo
11 | Prints the CTT logo in ASCII art format to the console.
12 | #>
13 |
14 | $asciiArt = @"
15 | CCCCCCCCCCCCCTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
16 | CCC::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T
17 | CC:::::::::::::::CT:::::::::::::::::::::TT:::::::::::::::::::::T
18 | C:::::CCCCCCCC::::CT:::::TT:::::::TT:::::TT:::::TT:::::::TT:::::T
19 | C:::::C CCCCCCTTTTTT T:::::T TTTTTTTTTTTT T:::::T TTTTTT
20 | C:::::C T:::::T T:::::T
21 | C:::::C T:::::T T:::::T
22 | C:::::C T:::::T T:::::T
23 | C:::::C T:::::T T:::::T
24 | C:::::C T:::::T T:::::T
25 | C:::::C T:::::T T:::::T
26 | C:::::C CCCCCC T:::::T T:::::T
27 | C:::::CCCCCCCC::::C TT:::::::TT TT:::::::TT
28 | CC:::::::::::::::C T:::::::::T T:::::::::T
29 | CCC::::::::::::C T:::::::::T T:::::::::T
30 | CCCCCCCCCCCCC TTTTTTTTTTT TTTTTTTTTTT
31 |
32 | ====Chris Titus Tech=====
33 | =====Windows Toolbox=====
34 | "@
35 |
36 | Write-Host $asciiArt
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/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 reworking the docs to use Hugo rather then mkdocs.
7 |
8 | {% endblock %}
9 |
10 | {% block footer %}
11 | {# Empty block to override the footer #}
12 | {% endblock %}
13 |
--------------------------------------------------------------------------------
/releases/oscdimg.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ChrisTitusTech/winutil/efb9e5bde6b333dfae15b157aafac5fed1fa1230/releases/oscdimg.exe
--------------------------------------------------------------------------------
/sign.bat:
--------------------------------------------------------------------------------
1 | signtool.exe sign /td sha256 /tr http://timestamp.digicert.com /fd sha256 /n "CT Tech Group LLC" .\winutil.ps1
2 |
--------------------------------------------------------------------------------