mirror of
https://github.com/ChrisTitusTech/winutil
synced 2026-06-04 14:17:27 +00:00
Remove Write-Debug (#4498)
* Update Invoke-WinUtilCurrentSystem.ps1 * Update Invoke-WinUtilFontScaling.ps1 * Update Invoke-WinUtilTweaks.ps1 * Update Reset-WPFCheckBoxes.ps1 * Update Set-Preferences.ps1 * Update Update-WinUtilSelections.ps1 * Update Invoke-WPFSelectedCheckboxesUpdate.ps1 * Update Invoke-WPFtweaksbutton.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Update main.ps1 * Merge branch 'main' into Remove-Write-Debug
This commit is contained in:
@@ -117,10 +117,6 @@ Function Invoke-WinUtilCurrentSystem {
|
||||
if ($values -notcontains $false) {
|
||||
Write-Output $Config
|
||||
}
|
||||
} else {
|
||||
if ($invokeScript -or $appxKeys) {
|
||||
Write-Debug "Skipping $Config in Get Installed: no detectable registry, scheduled task, or service state."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,6 @@ function Invoke-WinUtilFontScaling {
|
||||
# Calculates and applies the new font size
|
||||
$newValue = [math]::Round($originalValue * $ScaleFactor, 1)
|
||||
$sync.Form.Resources[$resourceName] = $newValue
|
||||
Write-Debug "Scaled $resourceName from original $originalValue to $newValue (factor: $ScaleFactor)"
|
||||
}
|
||||
}
|
||||
catch {
|
||||
@@ -80,8 +79,4 @@ function Invoke-WinUtilFontScaling {
|
||||
$percentage = [math]::Round($ScaleFactor * 100)
|
||||
$sync.FontScalingValue.Text = "$percentage%"
|
||||
}
|
||||
|
||||
Write-Debug "Font scaling applied with factor: $ScaleFactor"
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -21,8 +21,7 @@ function Invoke-WinUtilTweaks {
|
||||
$KeepServiceStartup = $true
|
||||
)
|
||||
|
||||
Write-Debug "Tweaks: $($CheckBox)"
|
||||
if($undo) {
|
||||
if ($undo) {
|
||||
$Values = @{
|
||||
Registry = "OriginalValue"
|
||||
Service = "OriginalType"
|
||||
@@ -37,18 +36,16 @@ function Invoke-WinUtilTweaks {
|
||||
ScriptType = "InvokeScript"
|
||||
}
|
||||
}
|
||||
if($sync.configs.tweaks.$CheckBox.service) {
|
||||
Write-Debug "KeepServiceStartup is $KeepServiceStartup"
|
||||
if ($sync.configs.tweaks.$CheckBox.service) {
|
||||
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
|
||||
$changeservice = $true
|
||||
|
||||
# The check for !($undo) is required, without it the script will throw an error for accessing unavailable member, which's the 'OriginalService' Property
|
||||
if($KeepServiceStartup -AND !($undo)) {
|
||||
if ($KeepServiceStartup -AND !($undo)) {
|
||||
try {
|
||||
# Check if the service exists
|
||||
$service = Get-Service -Name $psitem.Name -ErrorAction Stop
|
||||
if(!($service.StartType.ToString() -eq $psitem.$($values.OriginalService))) {
|
||||
Write-Debug "Service $($service.Name) was changed in the past to $($service.StartType.ToString()) from it's original type of $($psitem.$($values.OriginalService)), will not change it to $($psitem.$($values.service))"
|
||||
$changeservice = $false
|
||||
}
|
||||
} catch [System.ServiceProcess.ServiceNotFoundException] {
|
||||
@@ -56,41 +53,28 @@ function Invoke-WinUtilTweaks {
|
||||
}
|
||||
}
|
||||
|
||||
if($changeservice) {
|
||||
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.service))"
|
||||
if ($changeservice) {
|
||||
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
|
||||
}
|
||||
}
|
||||
}
|
||||
if($sync.configs.tweaks.$CheckBox.registry) {
|
||||
if ($sync.configs.tweaks.$CheckBox.registry) {
|
||||
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
|
||||
Write-Debug "$($psitem.Name) and state is $($psitem.$($values.registry))"
|
||||
if (($psitem.Path -imatch "hku") -and !(Get-PSDrive -Name HKU -ErrorAction SilentlyContinue)) {
|
||||
$null = (New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS)
|
||||
if (Get-PSDrive -Name HKU -ErrorAction SilentlyContinue) {
|
||||
Write-Debug "HKU drive created successfully."
|
||||
} else {
|
||||
Write-Debug "Failed to create HKU drive."
|
||||
}
|
||||
}
|
||||
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
|
||||
}
|
||||
}
|
||||
if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)) {
|
||||
if ($sync.configs.tweaks.$CheckBox.$($values.ScriptType)) {
|
||||
$sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object {
|
||||
Write-Debug "$($psitem) and state is $($psitem.$($values.ScriptType))"
|
||||
$Scriptblock = [scriptblock]::Create($psitem)
|
||||
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
|
||||
}
|
||||
}
|
||||
|
||||
if(!$undo) {
|
||||
if (!$undo) {
|
||||
if($sync.configs.tweaks.$CheckBox.appx) {
|
||||
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
|
||||
Write-Debug "UNDO $($psitem.Name)"
|
||||
Remove-WinUtilAPPX -Name $psitem
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,14 +23,6 @@ function Reset-WPFCheckBoxes {
|
||||
|
||||
$CheckBoxesToCheck = $sync.selectedApps + $sync.selectedTweaks + $sync.selectedFeatures
|
||||
$CheckBoxes = ($sync.GetEnumerator()).where{ $_.Value -is [System.Windows.Controls.CheckBox] -and $_.Name -notlike "WPFToggle*" -and $_.Name -like "$checkboxfilterpattern"}
|
||||
Write-Debug "Getting checkboxes to set, number of checkboxes: $($CheckBoxes.Count)"
|
||||
|
||||
if ($CheckBoxesToCheck -ne "") {
|
||||
$debugMsg = "CheckBoxes to Check are: "
|
||||
$CheckBoxesToCheck | ForEach-Object { $debugMsg += "$_, " }
|
||||
$debugMsg = $debugMsg -replace (',\s*$', '')
|
||||
Write-Debug "$debugMsg"
|
||||
}
|
||||
|
||||
foreach ($CheckBox in $CheckBoxes) {
|
||||
$checkboxName = $CheckBox.Key
|
||||
@@ -43,11 +35,9 @@ function Reset-WPFCheckBoxes {
|
||||
if ($CheckBoxesToCheck -contains $checkboxName) {
|
||||
# If it exists, set IsChecked to true
|
||||
$sync.$checkboxName.IsChecked = $true
|
||||
Write-Debug "$checkboxName is checked"
|
||||
} else {
|
||||
# If it doesn't exist, set IsChecked to false
|
||||
$sync.$checkboxName.IsChecked = $false
|
||||
Write-Debug "$checkboxName is not checked"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +58,6 @@ function Reset-WPFCheckBoxes {
|
||||
foreach ($toggle in $allToggles) {
|
||||
if ($importedToggles -contains $toggle.Key) {
|
||||
$sync[$toggle.Key].IsChecked = $true
|
||||
Write-Debug "Restoring toggle: $($toggle.Key) = checked"
|
||||
}
|
||||
# Toggles not present in the import are intentionally left untouched;
|
||||
# their current UI state already reflects the real system state.
|
||||
|
||||
@@ -34,7 +34,6 @@ function Set-Preferences{
|
||||
$ini = ""
|
||||
foreach($key in $sync.preferences.Keys) {
|
||||
$pref = "$($key)=$($sync.preferences.$key)"
|
||||
Write-Debug "Saving pref: $($pref)"
|
||||
$ini = $ini + $pref + "`r`n"
|
||||
}
|
||||
$ini | Out-File $iniPath
|
||||
@@ -49,7 +48,6 @@ function Set-Preferences{
|
||||
$arr = $line -split "=",-2
|
||||
$key = $arr[0] -replace "\s",""
|
||||
$value = $arr[1] -replace "\s",""
|
||||
Write-Debug "Preference: Key = '$($key)' Value ='$($value)'"
|
||||
$sync.preferences.$key = $value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,6 @@ function Update-WinUtilSelections {
|
||||
$flatJson
|
||||
)
|
||||
|
||||
Write-Debug "JSON to import: $($flatJson)"
|
||||
|
||||
foreach ($item in $flatJson) {
|
||||
# Ensure each item is treated as a string to handle PSCustomObject from JSON deserialization
|
||||
$cbkey = [string]$item
|
||||
@@ -51,11 +49,4 @@ function Update-WinUtilSelections {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Debug "-------------------------------------"
|
||||
Write-Debug "Selected Apps: $($sync.selectedApps)"
|
||||
Write-Debug "Selected Tweaks: $($sync.selectedTweaks)"
|
||||
Write-Debug "Selected Toggles: $($sync.selectedToggles)"
|
||||
Write-Debug "Selected Features: $($sync.selectedFeatures)"
|
||||
Write-Debug "--------------------------------------"
|
||||
}
|
||||
|
||||
@@ -85,11 +85,4 @@ function Invoke-WPFSelectedCheckboxesUpdate{
|
||||
Write-Host "Unknown group for checkbox: $($appKey)"
|
||||
}
|
||||
}
|
||||
|
||||
Write-Debug "-------------------------------------"
|
||||
Write-Debug "Selected Apps: $($sync.selectedApps)"
|
||||
Write-Debug "Selected Tweaks: $($sync.selectedTweaks)"
|
||||
Write-Debug "Selected Toggles: $($sync.selectedToggles)"
|
||||
Write-Debug "Selected Features: $($sync.selectedFeatures)"
|
||||
Write-Debug "--------------------------------------"
|
||||
}
|
||||
|
||||
@@ -29,8 +29,6 @@ function Invoke-WPFtweaksbutton {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Debug "Number of tweaks to process: $($Tweaks.Count)"
|
||||
|
||||
if ($restorePointSelected) {
|
||||
$sync.ProcessRunning = $true
|
||||
|
||||
@@ -58,7 +56,6 @@ function Invoke-WPFtweaksbutton {
|
||||
# The leading "," in the ParameterList is necessary because we only provide one argument and powershell cannot be convinced that we want a nested loop with only one argument otherwise
|
||||
$handle = Invoke-WPFRunspace -ParameterList @(("tweaks", $tweaksToRun), ("dnsProvider", $dnsProvider), ("completedSteps", $completedSteps), ("totalSteps", $totalSteps)) -ScriptBlock {
|
||||
param($tweaks, $dnsProvider, $completedSteps, $totalSteps)
|
||||
Write-Debug "Inside Number of tweaks to process: $($Tweaks.Count)"
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
|
||||
|
||||
@@ -13,14 +13,12 @@ $maxthreads = [int]$env:NUMBER_OF_PROCESSORS
|
||||
|
||||
# Create a new session state for parsing variables into our runspace
|
||||
$hashVars = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'sync',$sync,$Null
|
||||
$debugVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'DebugPreference',$DebugPreference,$Null
|
||||
$uiVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_NOUI',$PARAM_NOUI,$Null
|
||||
$offlineVar = New-object System.Management.Automation.Runspaces.SessionStateVariableEntry -ArgumentList 'PARAM_OFFLINE',$PARAM_OFFLINE,$Null
|
||||
$InitialSessionState = [System.Management.Automation.Runspaces.InitialSessionState]::CreateDefault()
|
||||
|
||||
# Add the variable to the session state
|
||||
$InitialSessionState.Variables.Add($hashVars)
|
||||
$InitialSessionState.Variables.Add($debugVar)
|
||||
$InitialSessionState.Variables.Add($uiVar)
|
||||
$InitialSessionState.Variables.Add($offlineVar)
|
||||
|
||||
@@ -210,7 +208,6 @@ $sync.keys | ForEach-Object {
|
||||
$sync["$psitem"].Add_MouseUp({
|
||||
[System.Object]$Sender = $args[0]
|
||||
Start-Process $Sender.ToolTip -ErrorAction Stop
|
||||
Write-Debug "Opening: $($Sender.ToolTip)"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -316,7 +313,6 @@ $sync["Form"].Add_MouseDoubleClick({
|
||||
})
|
||||
|
||||
$sync["Form"].Add_Deactivated({
|
||||
Write-Debug "WinUtil lost focus"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings", "Theme", "FontScaling")
|
||||
})
|
||||
|
||||
@@ -330,10 +326,6 @@ $sync["Form"].Add_ContentRendered({
|
||||
$screenWidth = $primaryScreen.Bounds.Width
|
||||
$screenHeight = $primaryScreen.Bounds.Height
|
||||
|
||||
# Print the screen size
|
||||
Write-Debug "Primary Monitor Width: $screenWidth pixels"
|
||||
Write-Debug "Primary Monitor Height: $screenHeight pixels"
|
||||
|
||||
# Compare with the primary monitor size
|
||||
if ($sync.Form.ActualWidth -gt $screenWidth -or $sync.Form.ActualHeight -gt $screenHeight) {
|
||||
Write-Debug "The specified width and/or height is greater than the primary monitor size."
|
||||
@@ -341,11 +333,7 @@ $sync["Form"].Add_ContentRendered({
|
||||
$sync.Form.Top = 0
|
||||
$sync.Form.Width = $screenWidth
|
||||
$sync.Form.Height = $screenHeight
|
||||
} else {
|
||||
Write-Debug "The specified width and height are within the primary monitor size limits."
|
||||
}
|
||||
} else {
|
||||
Write-Debug "Unable to retrieve information about the primary monitor."
|
||||
}
|
||||
|
||||
if ($PARAM_OFFLINE) {
|
||||
@@ -445,41 +433,33 @@ $sync["Form"].Add_Activated({
|
||||
})
|
||||
|
||||
$sync["ThemeButton"].Add_Click({
|
||||
Write-Debug "ThemeButton clicked"
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Toggle"; "FontScaling" = "Hide" }
|
||||
})
|
||||
$sync["AutoThemeMenuItem"].Add_Click({
|
||||
Write-Debug "About clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Auto"
|
||||
})
|
||||
$sync["DarkThemeMenuItem"].Add_Click({
|
||||
Write-Debug "Dark Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Dark"
|
||||
})
|
||||
$sync["LightThemeMenuItem"].Add_Click({
|
||||
Write-Debug "Light Theme clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Theme")
|
||||
Invoke-WinutilThemeChange -theme "Light"
|
||||
})
|
||||
|
||||
$sync["SettingsButton"].Add_Click({
|
||||
Write-Debug "SettingsButton clicked"
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Toggle"; "Theme" = "Hide"; "FontScaling" = "Hide" }
|
||||
})
|
||||
$sync["ImportMenuItem"].Add_Click({
|
||||
Write-Debug "Import clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "import"
|
||||
})
|
||||
$sync["ExportMenuItem"].Add_Click({
|
||||
Write-Debug "Export clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Invoke-WPFImpex -type "export"
|
||||
})
|
||||
$sync["AboutMenuItem"].Add_Click({
|
||||
Write-Debug "About clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
@@ -492,12 +472,10 @@ Version : <a href="https://github.com/ChrisTitusTech/winutil/releases/tag/$($sy
|
||||
Show-CustomDialog -Title "About" -Message $authorInfo
|
||||
})
|
||||
$sync["DocumentationMenuItem"].Add_Click({
|
||||
Write-Debug "Documentation clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
Start-Process "https://winutil.christitus.com/"
|
||||
})
|
||||
$sync["SponsorMenuItem"].Add_Click({
|
||||
Write-Debug "Sponsors clicked"
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("Settings")
|
||||
|
||||
$authorInfo = @"
|
||||
@@ -517,7 +495,6 @@ $sync["SponsorMenuItem"].Add_Click({
|
||||
|
||||
# Font Scaling Event Handlers
|
||||
$sync["FontScalingButton"].Add_Click({
|
||||
Write-Debug "FontScalingButton clicked"
|
||||
Invoke-WPFPopup -PopupActionTable @{ "Settings" = "Hide"; "Theme" = "Hide"; "FontScaling" = "Toggle" }
|
||||
})
|
||||
|
||||
@@ -528,13 +505,11 @@ $sync["FontScalingSlider"].Add_ValueChanged({
|
||||
})
|
||||
|
||||
$sync["FontScalingResetButton"].Add_Click({
|
||||
Write-Debug "FontScalingResetButton clicked"
|
||||
$sync.FontScalingSlider.Value = 1.0
|
||||
$sync.FontScalingValue.Text = "100%"
|
||||
})
|
||||
|
||||
$sync["FontScalingApplyButton"].Add_Click({
|
||||
Write-Debug "FontScalingApplyButton clicked"
|
||||
$scaleFactor = $sync.FontScalingSlider.Value
|
||||
Invoke-WinUtilFontScaling -ScaleFactor $scaleFactor
|
||||
Invoke-WPFPopup -Action "Hide" -Popups @("FontScaling")
|
||||
@@ -547,49 +522,40 @@ $sync["WPFTab5BT"].Add_Click({
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOBrowseButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOBrowseButton clicked"
|
||||
Invoke-WinUtilISOBrowse
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISODownloadLink"].Add_Click({
|
||||
Write-Debug "WPFWin11ISODownloadLink clicked"
|
||||
Start-Process "https://www.microsoft.com/software-download/windows11"
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOMountButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOMountButton clicked"
|
||||
Invoke-WinUtilISOMountAndVerify
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOModifyButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOModifyButton clicked"
|
||||
Invoke-WinUtilISOModify
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOChooseISOButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOChooseISOButton clicked"
|
||||
$sync["WPFWin11ISOOptionUSB"].Visibility = "Collapsed"
|
||||
Invoke-WinUtilISOExport
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOChooseUSBButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOChooseUSBButton clicked"
|
||||
$sync["WPFWin11ISOOptionUSB"].Visibility = "Visible"
|
||||
Invoke-WinUtilISORefreshUSBDrives
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISORefreshUSBButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISORefreshUSBButton clicked"
|
||||
Invoke-WinUtilISORefreshUSBDrives
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOWriteUSBButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOWriteUSBButton clicked"
|
||||
Invoke-WinUtilISOWriteUSB
|
||||
})
|
||||
|
||||
$sync["WPFWin11ISOCleanResetButton"].Add_Click({
|
||||
Write-Debug "WPFWin11ISOCleanResetButton clicked"
|
||||
Invoke-WinUtilISOCleanAndReset
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user