Remove All Trailing Whitespace Characters in '.ps1' Files

This commit is contained in:
Mr.k 2024-06-23 09:01:57 +03:00
parent 864f063878
commit c8a448d465
No known key found for this signature in database
28 changed files with 165 additions and 165 deletions

View File

@ -1,27 +1,27 @@
function ConvertTo-Icon {
function ConvertTo-Icon {
<#
.DESCRIPTION
This function will convert PNG to ICO file
.EXAMPLE
ConvertTo-Icon -bitmapPath "$env:TEMP\cttlogo.png" -iconPath $iconPath
#>
param( [Parameter(Mandatory=$true)]
$bitmapPath,
param( [Parameter(Mandatory=$true)]
$bitmapPath,
$iconPath = "$env:temp\newicon.ico"
)
Add-Type -AssemblyName System.Drawing
if (Test-Path $bitmapPath) {
$b = [System.Drawing.Bitmap]::FromFile($bitmapPath)
$icon = [System.Drawing.Icon]::FromHandle($b.GetHicon())
$file = New-Object System.IO.FileStream($iconPath, 'OpenOrCreate')
$icon.Save($file)
$file.Close()
$icon.Dispose()
#explorer "/SELECT,$iconpath"
}
else { Write-Warning "$BitmapPath does not exist" }
)
Add-Type -AssemblyName System.Drawing
if (Test-Path $bitmapPath) {
$b = [System.Drawing.Bitmap]::FromFile($bitmapPath)
$icon = [System.Drawing.Icon]::FromHandle($b.GetHicon())
$file = New-Object System.IO.FileStream($iconPath, 'OpenOrCreate')
$icon.Save($file)
$file.Close()
$icon.Dispose()
#explorer "/SELECT,$iconpath"
}
else { Write-Warning "$BitmapPath does not exist" }
}

View File

@ -1,22 +1,22 @@
function Copy-Files {
<#
.DESCRIPTION
This function will make all modifications to the registry
.EXAMPLE
Set-WinUtilRegistry -Name "PublishUserActivities" -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\System" -Type "DWord" -Value "0"
#>
#>
param (
[string] $Path,
[string] $Destination,
[switch] $Recurse = $false,
[string] $Path,
[string] $Destination,
[switch] $Recurse = $false,
[switch] $Force = $false
)
try {
try {
$files = Get-ChildItem -Path $path -Recurse:$recurse
Write-Host "Copy $($files.Count)(s) from $path to $destination"
@ -35,9 +35,9 @@ function Copy-Files {
else
{
Write-Debug "Copy from $($file.FullName) to $($destination+$restpath)"
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force
Copy-Item $file.FullName ($destination+$restpath) -ErrorAction SilentlyContinue -Force:$force
Set-ItemProperty -Path ($destination+$restpath) -Name IsReadOnly -Value $false
}
}
}
Write-Progress -Activity "Copy Windows files" -Status "Ready" -Completed
}

View File

@ -1,17 +1,17 @@
function Get-LocalizedYesNo {
<#
.SYNOPSIS
This function runs choice.exe and captures its output to extract yes no in a localized Windows
This function runs choice.exe and captures its output to extract yes no in a localized Windows
.DESCRIPTION
The function retrieves the output of the command 'cmd /c "choice <nul 2>nul"' and converts the default output for Yes and No
in the localized format, such as "Yes=<first character>, No=<second character>".
.EXAMPLE
$yesNoArray = Get-LocalizedYesNo
Write-Host "Yes=$($yesNoArray[0]), No=$($yesNoArray[1])"
#>
# Run choice and capture its options as output
# The output shows the options for Yes and No as "[Y,N]?" in the (partitially) localized format.
# eg. English: [Y,N]?
@ -21,7 +21,7 @@ function Get-LocalizedYesNo {
# Spanish: [S,N]?
# Italian: [S,N]?
# Russian: [Y,N]?
$line = cmd /c "choice <nul 2>nul"
$charactersArray = @()
$regexPattern = '([a-zA-Z])'
@ -31,51 +31,51 @@ function Get-LocalizedYesNo {
# Return the array of characters
return $charactersArray
}
function Get-LocalizedYesNoTakeown {
<#
.SYNOPSIS
This function runs takeown.exe and captures its output to extract yes no in a localized Windows
This function runs takeown.exe and captures its output to extract yes no in a localized Windows
.DESCRIPTION
The function retrieves lines from the output of takeown.exe until there are at least 2 characters
captured in a specific format, such as "Yes=<first character>, No=<second character>".
.EXAMPLE
$yesNoArray = Get-LocalizedYesNo
Write-Host "Yes=$($yesNoArray[0]), No=$($yesNoArray[1])"
#>
# Run takeown.exe and capture its output
$takeownOutput = & takeown.exe /? | Out-String
# Parse the output and retrieve lines until there are at least 2 characters in the array
$found = $false
$charactersArray = @()
foreach ($line in $takeownOutput -split "`r`n")
foreach ($line in $takeownOutput -split "`r`n")
{
# skip everything before /D flag help
if ($found)
if ($found)
{
# now that /D is found start looking for a single character in double quotes
# in help text there is another string in double quotes but it is not a single character
$regexPattern = '"([a-zA-Z])"'
$charactersArray = [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
# if ($charactersArray.Count -gt 0) {
# Write-Output "Extracted symbols: $($matches -join ', ')"
# } else {
# Write-Output "No matches found."
# }
if ($charactersArray.Count -ge 2)
if ($charactersArray.Count -ge 2)
{
break
}
}
}
elseif ($line -match "/D ")
elseif ($line -match "/D ")
{
$found = $true
}

View File

@ -1,13 +1,13 @@
function Get-Oscdimg {
function Get-Oscdimg {
<#
.DESCRIPTION
This function will download oscdimg file from github Release folders and put it into env:temp folder
.EXAMPLE
Get-Oscdimg
#>
param( [Parameter(Mandatory=$true)]
param( [Parameter(Mandatory=$true)]
[string]$oscdimgPath
)
$oscdimgPath = "$env:TEMP\oscdimg.exe"
@ -24,4 +24,4 @@ function Get-Oscdimg {
} else {
Write-Host "Hashes do not match. File may be corrupted or tampered with."
}
}
}

View File

@ -13,8 +13,8 @@ function Get-TabXaml {
.EXAMPLE
Get-TabXaml "applications" 3
#>
param( [Parameter(Mandatory=$true)]
$tabname,
$columncount = 0
@ -80,7 +80,7 @@ function Get-TabXaml {
# Dot-source the Get-WPFObjectName function
. .\functions\private\Get-WPFObjectName
$categorycontent = $($category -replace '^.__', '')
$categoryname = Get-WPFObjectName -type "Label" -name $categorycontent
$blockXml += "<Label Name=""$categoryname"" Content=""$categorycontent"" FontSize=""16""/>`n"

View File

@ -10,17 +10,17 @@ function Get-WPFObjectName {
.OUTPUTS
A string that can be used as a object/variable name in powershell.
For example: WPFLabelMicrosoftTools
.EXAMPLE
Get-WPFObjectName -type Label -name "Microsoft Tools"
#>
param( [Parameter(Mandatory=$true)]
$type,
param( [Parameter(Mandatory=$true)]
$type,
$name
)
$Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
$Output = $("WPF"+$type+$name) -replace '[^a-zA-Z0-9]', ''
return $Output

View File

@ -49,7 +49,7 @@ Function Get-WinUtilToggleStatus {
else{
return $false
}
}
}
if($ToggleSwitch -eq "WPFToggleShowExt"){
$hideextvalue = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').HideFileExt
if($hideextvalue -eq 0){
@ -58,7 +58,7 @@ Function Get-WinUtilToggleStatus {
else{
return $false
}
}
}
if($ToggleSwitch -eq "WPFToggleSnapWindow"){
$hidesnap = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WindowArrangementActive
if($hidesnap -eq 0){
@ -76,7 +76,7 @@ Function Get-WinUtilToggleStatus {
else{
return $true
}
}
}
if($ToggleSwitch -eq "WPFToggleSnapSuggestion"){
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').SnapAssist
if($hidesnap -eq 0){
@ -85,7 +85,7 @@ Function Get-WinUtilToggleStatus {
else{
return $true
}
}
}
if($ToggleSwitch -eq "WPFToggleMouseAcceleration"){
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1

View File

@ -5,8 +5,8 @@ function Get-WinUtilWingetLatest {
.DESCRIPTION
This function grabs the latest version of Winget and returns the download path to Install-WinUtilWinget for installation.
#>
# 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
$PreviousProgressPreference = $ProgressPreference
# 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
$PreviousProgressPreference = $ProgressPreference
$ProgressPreference = "silentlyContinue"
Try{
# Grabs the latest release of Winget from the Github API for the install process.

View File

@ -2,17 +2,17 @@ function Install-WinUtilProgramChoco {
<#
.SYNOPSIS
Manages the provided programs using Chocolatey
.PARAMETER ProgramsToInstall
A list of programs to manage
.PARAMETER manage
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
.NOTES
The triple quotes are required any time you need a " in a normal script block.
#>
param(
[Parameter(Mandatory, Position=0)]
[PsCustomObject]$ProgramsToInstall,
@ -20,7 +20,7 @@ function Install-WinUtilProgramChoco {
[Parameter(Position=1)]
[String]$manage = "Installing"
)
$x = 0
$count = $ProgramsToInstall.Count

View File

@ -1,30 +1,30 @@
Function Install-WinUtilProgramWinget {
<#
.SYNOPSIS
Manages the provided programs using Winget
.PARAMETER ProgramsToInstall
A list of programs to manage
.PARAMETER manage
The action to perform on the programs, can be either 'Installing' or 'Uninstalling'
.NOTES
The triple quotes are required any time you need a " in a normal script block.
The winget Return codes are documented here: https://github.com/microsoft/winget-cli/blob/master/doc/windows/package-manager/winget/returnCodes.md
#>
param(
[Parameter(Mandatory, Position=0)]
[PsCustomObject]$ProgramsToInstall,
[Parameter(Position=1)]
[String]$manage = "Installing"
)
$x = 0
$count = $ProgramsToInstall.Count
Write-Progress -Activity "$manage Applications" -Status "Starting" -PercentComplete 0
Write-Host "==========================================="
Write-Host "-- Configuring winget packages ---"
@ -33,7 +33,7 @@ Function Install-WinUtilProgramWinget {
$failedPackages = @()
Write-Progress -Activity "$manage Applications" -Status "$manage $($Program.winget) $($x + 1) of $count" -PercentComplete $($x/$count*100)
if($manage -eq "Installing"){
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Install package via ID, if it fails try again with different scope and then with an unelevated prompt.
# Since Install-WinGetPackage might not be directly available, we use winget install command as a workaround.
# Winget, not all installers honor any of the following: System-wide, User Installs, or Unelevated Prompt OR Silent Install Mode.
# This is up to the individual package maintainers to enable these options. Aka. not as clean as Linux Package Managers.

View File

@ -41,7 +41,7 @@ function Install-WinUtilWinget {
Write-Host "Installing Winget w/ Prerequsites`r"
Add-AppxProvisionedPackage -Online -PackagePath $ENV:TEMP\Microsoft.DesktopAppInstaller.msixbundle -DependencyPackagePath $ENV:TEMP\Microsoft.VCLibs.x64.Desktop.appx, $ENV:TEMP\Microsoft.UI.Xaml.x64.appx -LicensePath $ENV:TEMP\License1.xml
Write-Host "Manually adding Winget Sources, from Winget CDN."
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time.
Add-AppxPackage -Path https://cdn.winget.microsoft.com/cache/source.msix #Seems some installs of Winget don't add the repo source, this should makes sure that it's installed every time.
Write-Host "Winget Installed" -ForegroundColor Green
Write-Host "Enabling NuGet and Module..."
Install-PackageProvider -Name NuGet -Force

View File

@ -121,8 +121,8 @@ function Remove-Packages
$_ -NotLike "*DesktopAppInstaller*" -AND
$_ -NotLike "*WebMediaExtensions*" -AND
$_ -NotLike "*WMIC*" -AND
$_ -NotLike "*UI.XaML*"
}
$_ -NotLike "*UI.XaML*"
}
foreach ($pkg in $pkglist)
{
@ -164,9 +164,9 @@ function Remove-ProvisionedPackages([switch] $keepSecurity = $false)
$_.PackageName -NotLike "*Notepad*" -and
$_.PackageName -NotLike "*Printing*" -and
$_.PackageName -NotLike "*Wifi*" -and
$_.PackageName -NotLike "*Foundation*"
}
$_.PackageName -NotLike "*Foundation*"
}
if ($?)
{
if ($keepSecurity) { $appxProvisionedPackages = $appxProvisionedPackages | Where-Object { $_.PackageName -NotLike "*SecHealthUI*" }}
@ -227,13 +227,13 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
# Remove-Item -Path $directoryPath -Recurse -Force
# # Grant full control to BUILTIN\Administrators using icacls
# $directoryPath = "$($scratchDir)\Windows\System32\WebThreatDefSvc"
# $directoryPath = "$($scratchDir)\Windows\System32\WebThreatDefSvc"
# takeown /a /r /d $yesNo[0] /f "$($directoryPath)" > $null
# icacls "$($directoryPath)" /q /c /t /reset > $null
# icacls $directoryPath /setowner "*S-1-5-32-544"
# icacls $directoryPath /grant "*S-1-5-32-544:(OI)(CI)F" /t /c /q
# Remove-Item -Path $directoryPath -Recurse -Force
$itemsToDelete = [System.Collections.ArrayList]::new()
if ($mask -eq "")
@ -241,9 +241,9 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
Write-Debug "Adding $($pathToDelete) to array."
[void]$itemsToDelete.Add($pathToDelete)
}
else
else
{
Write-Debug "Adding $($pathToDelete) to array and mask is $($mask)"
Write-Debug "Adding $($pathToDelete) to array and mask is $($mask)"
if ($Directory) { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse -Directory }
else { $itemsToDelete = Get-ChildItem $pathToDelete -Include $mask -Recurse }
}
@ -253,7 +253,7 @@ function Remove-FileOrDirectory([string] $pathToDelete, [string] $mask = "", [sw
$status = "Deleting $($itemToDelete)"
Write-Progress -Activity "Removing Items" -Status $status -PercentComplete ($counter++/$itemsToDelete.Count*100)
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
if (Test-Path -Path "$($itemToDelete)" -PathType Container)
{
$status = "Deleting directory: $($itemToDelete)"
@ -473,16 +473,16 @@ function New-FirstRun {
param (
[Parameter(Mandatory = $true)]
[string]$RegistryPath,
[Parameter(Mandatory = $true)]
[string]$ValueName
)
# Check if the registry path exists
if (Test-Path -Path $RegistryPath)
{
$registryValue = Get-ItemProperty -Path $RegistryPath -Name $ValueName -ErrorAction SilentlyContinue
# Check if the registry value exists
if ($registryValue)
{
@ -500,7 +500,7 @@ function New-FirstRun {
Write-Host "Registry path '$RegistryPath' not found."
}
}
function Stop-UnnecessaryServices
{
$servicesToExclude = @(
@ -566,8 +566,8 @@ function New-FirstRun {
"vm3dservice",
"webthreatdefusersvc_dc2a4",
"wscsvc"
)
)
$runningServices = Get-Service | Where-Object { $servicesToExclude -notcontains $_.Name }
foreach($service in $runningServices)
{
@ -576,28 +576,28 @@ function New-FirstRun {
"Stopping service $($service.Name)" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber
}
}
"FirstStartup has worked" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber
$Theme = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize"
Set-ItemProperty -Path $Theme -Name AppsUseLightTheme -Value 1
Set-ItemProperty -Path $Theme -Name SystemUsesLightTheme -Value 1
# figure this out later how to set updates to security only
#Import-Module -Name PSWindowsUpdate;
#Import-Module -Name PSWindowsUpdate;
#Stop-Service -Name wuauserv
#Set-WUSettings -MicrosoftUpdateEnabled -AutoUpdateOption 'Never'
#Start-Service -Name wuauserv
Stop-UnnecessaryServices
$taskbarPath = "$env:AppData\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar"
# Delete all files on the Taskbar
# Delete all files on the Taskbar
Get-ChildItem -Path $taskbarPath -File | Remove-Item -Force
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesRemovedChanges"
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "FavoritesChanges"
Remove-RegistryValue -RegistryPath "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Taskband" -ValueName "Favorites"
# Stop-Process -Name explorer -Force
$process = Get-Process -Name "explorer"
@ -609,9 +609,9 @@ function New-FirstRun {
# Delete Edge Icon from the desktop
$edgeShortcutFiles = Get-ChildItem -Path $desktopPath -Filter "*Edge*.lnk"
# Check if Edge shortcuts exist on the desktop
if ($edgeShortcutFiles)
if ($edgeShortcutFiles)
{
foreach ($shortcutFile in $edgeShortcutFiles)
foreach ($shortcutFile in $edgeShortcutFiles)
{
# Remove each Edge shortcut
Remove-Item -Path $shortcutFile.FullName -Force
@ -631,7 +631,7 @@ function New-FirstRun {
$shortcutPath = Join-Path $desktopPath 'winutil.lnk'
# Create a shell object
$shell = New-Object -ComObject WScript.Shell
# Create a shortcut object
$shortcut = $shell.CreateShortcut($shortcutPath)
@ -639,26 +639,26 @@ function New-FirstRun {
{
$shortcut.IconLocation = "c:\Windows\cttlogo.png"
}
# Set properties of the shortcut
$shortcut.TargetPath = "powershell.exe"
$shortcut.Arguments = "-NoProfile -ExecutionPolicy Bypass -Command `"$command`""
# Save the shortcut
$shortcut.Save()
# Make the shortcut have 'Run as administrator' property on
$bytes = [System.IO.File]::ReadAllBytes($shortcutPath)
# Set byte value at position 0x15 in hex, or 21 in decimal, from the value 0x00 to 0x20 in hex
$bytes[0x15] = $bytes[0x15] -bor 0x20
[System.IO.File]::WriteAllBytes($shortcutPath, $bytes)
Write-Host "Shortcut created at: $shortcutPath"
#
#
# Done create WinUtil shortcut on the desktop
# ************************************************
Start-Process explorer
'@
$firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force
$firstRun | Out-File -FilePath "$env:temp\FirstStartup.ps1" -Force
}

View File

@ -1,6 +1,6 @@
function Invoke-WinUtilGPU {
$gpuInfo = Get-CimInstance Win32_VideoController
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*NVIDIA*") {
@ -11,19 +11,19 @@ function Invoke-WinUtilGPU {
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*AMD Radeon RX*") {
return $true # AMD GPU Found
return $true # AMD GPU Found
}
}
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*UHD*") {
return $false # Intel Intergrated GPU Found
return $false # Intel Intergrated GPU Found
}
}
foreach ($gpu in $gpuInfo) {
$gpuName = $gpu.Name
if ($gpuName -like "*AMD Radeon(TM)*") {
return $false # AMD Intergrated GPU Found
return $false # AMD Intergrated GPU Found
}
}
}

View File

@ -15,13 +15,13 @@ Function Invoke-WinUtilMouseAcceleration {
$MouseSpeed = 1
$MouseThreshold1 = 6
$MouseThreshold2 = 10
}
}
else {
Write-Host "Disabling Mouse Acceleration"
$MouseSpeed = 0
$MouseThreshold1 = 0
$MouseThreshold2 = 0
$MouseThreshold2 = 0
}
$Path = "HKCU:\Control Panel\Mouse"

View File

@ -6,7 +6,7 @@ Function Invoke-WinUtilStickyKeys {
Indicates whether to enable or disable Sticky Keys on startup
#>
Param($Enabled)
Try {
Try {
if ($Enabled -eq $false){
Write-Host "Enabling Sticky Keys On startup"
$value = 510

View File

@ -50,7 +50,7 @@ function Invoke-WinUtilTweaks {
Write-Debug "KeepServiceStartup is $KeepServiceStartup"
$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 memeber, which's the 'OriginalService' Property
if($KeepServiceStartup -AND !($undo)) {
try {

View File

@ -2,10 +2,10 @@ function Show-CustomDialog {
<#
.SYNOPSIS
Displays a custom dialog box with an image, heading, message, and an OK button.
.DESCRIPTION
This function creates a custom dialog box with the specified message and additional elements such as an image, heading, and an OK button. The dialog box is designed with a green border, rounded corners, and a black background.
.PARAMETER Message
The message to be displayed in the dialog box.
@ -14,10 +14,10 @@ function Show-CustomDialog {
.PARAMETER Height
The height of the custom dialog window.
.EXAMPLE
Show-CustomDialog -Message "This is a custom dialog with a message and an image above." -Width 300 -Height 200
#>
param(
[string]$Message,
@ -99,7 +99,7 @@ function Show-CustomDialog {
$grid.RowDefinitions.Add($row0)
$grid.RowDefinitions.Add($row1)
$grid.RowDefinitions.Add($row2)
# Add StackPanel for horizontal layout with margins
$stackPanel = New-Object Windows.Controls.StackPanel
$stackPanel.Margin = New-Object Windows.Thickness(10) # Add margins around the stack panel
@ -113,7 +113,7 @@ function Show-CustomDialog {
$viewbox = New-Object Windows.Controls.Viewbox
$viewbox.Width = 25
$viewbox.Height = 25
# Combine the paths into a single string
# $cttLogoPath = @"
# M174 1094 c-4 -14 -4 -55 -2 -92 3 -57 9 -75 41 -122 41 -60 45 -75 22 -84 -25 -9 -17 -21 30 -44 l45 -22 0 -103 c0 -91 3 -109 26 -155 30 -60 65 -87 204 -157 l95 -48 110 58 c184 96 205 127 205 293 l0 108 45 22 c47 23 55 36 30 46 -22 8 -18 30 9 63 13 16 34 48 46 71 20 37 21 52 15 116 l-6 73 -69 -23 c-38 -12 -137 -59 -220 -103 -82 -45 -160 -81 -171 -81 -12 0 -47 15 -78 34 -85 51 -239 127 -309 151 l-62 22 -6 -23z m500 -689 c20 -8 36 -19 36 -24 0 -18 -53 -51 -80 -51 -28 0 -80 33 -80 51 0 10 55 38 76 39 6 0 28 -7 48 -15z
@ -159,7 +159,7 @@ $cttLogoPath = @"
46.21,102.83 36.63,98.57 31.04,93.68
16.88,81.28 19.00,62.88 19.00,46.00 Z
"@
# Add SVG path
$svgPath = New-Object Windows.Shapes.Path
$svgPath.Data = [Windows.Media.Geometry]::Parse($cttLogoPath)
@ -167,7 +167,7 @@ $cttLogoPath = @"
# Add SVG path to Viewbox
$viewbox.Child = $svgPath
# Add SVG path to the stack panel
$stackPanel.Children.Add($viewbox)

View File

@ -70,7 +70,7 @@ function Test-WinUtilPackageManager {
Write-Host " - Winget is Out of Date" -ForegroundColor Red
$status = "outdated"
}
} else {
} else {
Write-Host "===========================================" -ForegroundColor Red
Write-Host "--- Winget is not installed ---" -ForegroundColor Red
Write-Host "===========================================" -ForegroundColor Red

View File

@ -8,13 +8,13 @@ function Invoke-ScratchDialog {
.PARAMETER Button
#>
$sync.WPFMicrowinISOScratchDir.IsChecked
$sync.WPFMicrowinISOScratchDir.IsChecked
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
$Dialog = New-Object System.Windows.Forms.FolderBrowserDialog
$Dialog.SelectedPath = $sync.MicrowinScratchDirBox.Text
$Dialog.ShowDialog()
$Dialog.ShowDialog()
$filePath = $Dialog.SelectedPath
Write-Host "No ISO is chosen+ $filePath"
@ -23,7 +23,7 @@ function Invoke-ScratchDialog {
Write-Host "No Folder had chosen"
return
}
$sync.MicrowinScratchDirBox.Text = Join-Path $filePath "\"
}

View File

@ -3,7 +3,7 @@ function Invoke-WPFFixesWinget {
<#
.SYNOPSIS
Fixes Winget by running choco install winget
Fixes Winget by running choco install winget
.DESCRIPTION
BravoNorris for the fantastic idea of a button to reinstall winget
#>

View File

@ -22,18 +22,18 @@ function Invoke-WPFGetIso {
Write-Host "/ /\/\ \| || (__ | | | (_) | \ /\ / | || | | | "
Write-Host "\/ \/|_| \___||_| \___/ \/ \/ |_||_| |_| "
$oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe'
$oscdimgPath = Join-Path $env:TEMP 'oscdimg.exe'
$oscdImgFound = [bool] (Get-Command -ErrorAction Ignore -Type Application oscdimg.exe) -or (Test-Path $oscdimgPath -PathType Leaf)
Write-Host "oscdimg.exe on system: $oscdImgFound"
if (!$oscdImgFound)
if (!$oscdImgFound)
{
$downloadFromGitHub = $sync.WPFMicrowinDownloadFromGitHub.IsChecked
$sync.BusyMessage.Visibility="Hidden"
if (!$downloadFromGitHub)
if (!$downloadFromGitHub)
{
# only show the message to people who did check the box to download from github, if you check the box
# only show the message to people who did check the box to download from github, if you check the box
# you consent to downloading it, no need to show extra dialogs
[System.Windows.MessageBox]::Show("oscdimge.exe is not found on the system, winutil will now attempt do download and install it using choco. This might take a long time.")
# the step below needs choco to download oscdimg
@ -41,7 +41,7 @@ function Invoke-WPFGetIso {
Install-WinUtilChoco
$chocoFound = [bool] (Get-Command -ErrorAction Ignore -Type Application choco)
Write-Host "choco on system: $chocoFound"
if (!$chocoFound)
if (!$chocoFound)
{
[System.Windows.MessageBox]::Show("choco.exe is not found on the system, you need choco to download oscdimg.exe")
return
@ -106,7 +106,7 @@ function Invoke-WPFGetIso {
Write-Host "You don't have enough space for this operation. You need at least $([Math]::Round(($isoSize / ([Math]::Pow(1024, 2))) * 2, 2)) MB of free space to copy the ISO files to a temp directory and to be able to perform additional operations."
return
}
else
else
{
Write-Host "You have enough space for this operation."
}
@ -144,7 +144,7 @@ function Invoke-WPFGetIso {
$sync.MicrowinScratchDirBox.Text = Join-Path $sync.MicrowinScratchDirBox.Text.Trim() '\'
}
# Detect if the folders already exist and remove them
if (($sync.MicrowinMountDir.Text -ne "") -and (Test-Path -Path $sync.MicrowinMountDir.Text))
{
@ -164,7 +164,7 @@ function Invoke-WPFGetIso {
$randomMicrowin = "Microwin_${timestamp}_${randomNumber}"
$randomMicrowinScratch = "MicrowinScratch_${timestamp}_${randomNumber}"
$sync.BusyText.Text=" - Mounting"
Write-Host "Mounting Iso. Please wait."
Write-Host "Mounting Iso. Please wait."
if ($sync.MicrowinScratchDirBox.Text -eq "") {
$mountDir = Join-Path $env:TEMP $randomMicrowin
$scratchDir = Join-Path $env:TEMP $randomMicrowinScratch
@ -180,12 +180,12 @@ function Invoke-WPFGetIso {
Write-Host "Image dir is $mountDir"
try {
#$data = @($driveLetter, $filePath)
New-Item -ItemType Directory -Force -Path "$($mountDir)" | Out-Null
New-Item -ItemType Directory -Force -Path "$($scratchDir)" | Out-Null
Write-Host "Copying Windows image. This will take awhile, please don't use UI or cancel this step!"
# xcopy we can verify files and also not copy files that already exist, but hard to measure
# xcopy.exe /E /I /H /R /Y /J $DriveLetter":" $mountDir >$null
$totalTime = Measure-Command { Copy-Files "$($driveLetter):" $mountDir -Recurse -Force }

View File

@ -33,12 +33,12 @@ function Invoke-WPFImpex {
if($FileBrowser.FileName -eq ""){
return
}
}
else{
$Config = $FileBrowser.FileName
}
}
if ($type -eq "export"){
$jsonFile = Get-WinUtilCheckBoxes -unCheck $false
$jsonFile | ConvertTo-Json | Out-File $FileBrowser.FileName -Force

View File

@ -92,7 +92,7 @@ public class PowerManagement {
$mountDirExists = Test-Path $mountDir
$scratchDirExists = Test-Path $scratchDir
if (-not $mountDirExists -or -not $scratchDirExists)
if (-not $mountDirExists -or -not $scratchDirExists)
{
Write-Error "Required directories '$mountDirExists' '$scratchDirExists' and do not exist."
return
@ -149,7 +149,7 @@ public class PowerManagement {
if (Test-Path "$env:TEMP\DRV_EXPORT")
{
Remove-Item "$env:TEMP\DRV_EXPORT" -Recurse -Force
}
}
}
}
@ -161,7 +161,7 @@ public class PowerManagement {
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
}
else
else
{
Write-Host "Path to drivers is invalid continuing without driver injection"
}
@ -182,12 +182,12 @@ public class PowerManagement {
}
# special code, for some reason when you try to delete some inbox apps
# we have to get and delete log files directory.
# we have to get and delete log files directory.
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LogFiles\WMI\RtBackup" -Directory
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\WebThreatDefSvc" -Directory
# Defender is hidden in 2 places we removed a feature above now need to remove it from the disk
if (!$keepDefender)
if (!$keepDefender)
{
Write-Host "Removing Defender"
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Defender" -Directory
@ -204,7 +204,7 @@ public class PowerManagement {
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\DiagTrack" -Directory
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\InboxApps" -Directory
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\SecurityHealthSystray.exe"
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LocationNotificationWindows.exe"
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\System32\LocationNotificationWindows.exe"
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Photo Viewer" -Directory
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files\Windows Photo Viewer" -Directory
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Program Files (x86)\Windows Media Player" -Directory
@ -285,7 +285,7 @@ public class PowerManagement {
Write-Host "Disabling Teams"
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v "ConfigureChatAutoInstall" /t REG_DWORD /d 0 /f >$null 2>&1
reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\Windows Chat" /v ChatIcon /t REG_DWORD /d 2 /f >$null 2>&1
reg add "HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "TaskbarMn" /t REG_DWORD /d 0 /f >$null 2>&1
reg add "HKLM\zNTUSER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" /v "TaskbarMn" /t REG_DWORD /d 0 /f >$null 2>&1
reg query "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\Communications" /v "ConfigureChatAutoInstall" >$null 2>&1
# Write-Host Error code $LASTEXITCODE
Write-Host "Done disabling Teams"
@ -327,7 +327,7 @@ public class PowerManagement {
reg add "HKLM\zSOFTWARE\Policies\Microsoft\Windows\CloudContent" /v "DisableWindowsConsumerFeatures" /t REG_DWORD /d 1 /f
reg add "HKLM\zSOFTWARE\Microsoft\PolicyManager\current\device\Start" /v "ConfigureStartPins" /t REG_SZ /d '{\"pinnedList\": [{}]}' /f
Write-Host "Done removing Sponsored Apps"
Write-Host "Disabling Reserved Storage"
reg add "HKLM\zSOFTWARE\Microsoft\Windows\CurrentVersion\ReserveManager" /v "ShippedWithReserves" /t REG_DWORD /d 0 /f
@ -351,8 +351,8 @@ public class PowerManagement {
Write-Host "Unmounting image..."
Dismount-WindowsImage -Path $scratchDir -Save
}
}
try {
Write-Host "Exporting image into $mountDir\sources\install2.wim"
@ -368,7 +368,7 @@ public class PowerManagement {
}
Write-Host "Windows image completed. Continuing with boot.wim."
# Next step boot image
# Next step boot image
Write-Host "Mounting boot image $mountDir\sources\boot.wim into $scratchDir"
Mount-WindowsImage -ImagePath "$mountDir\sources\boot.wim" -Index 2 -Path "$scratchDir"
@ -380,12 +380,12 @@ public class PowerManagement {
Write-Host "Adding Windows Drivers image($scratchDir) drivers($driverPath) "
dism /English /image:$scratchDir /add-driver /driver:$driverPath /recurse | Out-Host
}
else
else
{
Write-Host "Path to drivers is invalid continuing without driver injection"
}
}
Write-Host "Loading registry..."
reg load HKLM\zCOMPONENTS "$($scratchDir)\Windows\System32\config\COMPONENTS" >$null
reg load HKLM\zDEFAULT "$($scratchDir)\Windows\System32\config\default" >$null
@ -449,7 +449,7 @@ public class PowerManagement {
Copy-ToUSB("$($SaveDialog.FileName)")
if ($?) { Write-Host "Done Copying target ISO to USB drive!" } else { Write-Host "ISO copy failed." }
}
Write-Host " _____ "
Write-Host "(____ \ "
Write-Host " _ \ \ ___ ____ ____ "
@ -469,9 +469,9 @@ public class PowerManagement {
} else {
Write-Host "ISO creation failed. The "$($mountDir)" directory has not been removed."
}
$sync.MicrowinOptionsPanel.Visibility = 'Collapsed'
#$sync.MicrowinFinalIsoLocation.Text = "$env:temp\microwin.iso"
$sync.MicrowinFinalIsoLocation.Text = "$($SaveDialog.FileName)"
# Allow the machine to sleep again (optional)

View File

@ -20,7 +20,7 @@ function Invoke-WPFOOSU {
$ProgressPreference = "SilentlyContinue" # Disables the Progress Bar to drasticly speed up Invoke-WebRequest
Invoke-WebRequest -Uri "https://dl5.oo-software.com/files/ooshutup10/OOSU10.exe" -OutFile $OOSU_filepath
switch ($action)
switch ($action)
{
"customize"{
Write-Host "Starting OO Shutup 10 ..."

View File

@ -35,7 +35,7 @@ function Invoke-WPFPresets {
Write-Debug $_
}
}
foreach ($CheckBox in $CheckBoxes) {
$checkboxName = $CheckBox.Key

View File

@ -12,7 +12,7 @@ function Invoke-WPFTweakPS7{
)
switch ($action) {
"PS7"{
"PS7"{
if (Test-Path -Path "$env:ProgramFiles\PowerShell\7") {
Write-Host "Powershell 7 is already installed."
} else {
@ -41,6 +41,6 @@ function Invoke-WPFTweakPS7{
}
} else {
Write-Host "Settings file not found at $settingsPath"
}
}
}

View File

@ -13,7 +13,7 @@ function Invoke-WPFtweaksbutton {
}
$Tweaks = (Get-WinUtilCheckBoxes)["WPFTweaks"]
Set-WinUtilDNS -DNSProvider $sync["WPFchangedns"].text
if ($tweaks.count -eq 0 -and $sync["WPFchangedns"].text -eq "Default"){

View File

@ -278,7 +278,7 @@ Add-Type @"
$windowHandle = $proc.MainWindowHandle
} else {
Write-Warning "Process found, but no MainWindowHandle: $($proc.Id) $($proc.MainWindowTitle)"
}
}
@ -375,7 +375,7 @@ $filter = Get-WinUtilVariables -Type Label
$labels = @{}
$sync.GetEnumerator() | Where-Object {$PSItem.Key -in $filter} | ForEach-Object {$labels[$_.Key] = $_.Value}
$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
$allCategories = $checkBoxes.Name | ForEach-Object {$sync.configs.applications.$_} | Select-Object -Unique -ExpandProperty category
$sync["CheckboxFilter"].Add_TextChanged({