mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2025-06-27 16:44:46 -05:00
Test 2024 01 03 (#1384)
* Increase performance during loading. (#1348) * Increase performance during loading. Add a clear button to the search box. Add link and description attributes to the applications JSON. Use the link for linking to the app website. Use the description as a tooltip for each app. Add a clickable link to the website for each application (this took a long time; don't kick me if I got some wrong). Pressing Escape now clears the filter box. Pressing Alt-P prints your PID. * Fix for services that are being stopped * Compile winutil * Adding new Get-LocalizedYesNo based on choice.exe which is faster and more reliable, thank you @dtm-r for implementing it and testing it on English, German, Dutch, French, Italian, Spansich and Russian. Incredible work by @dtm-r, all cridit and props go to him. See this thread for details https://github.com/ChrisTitusTech/winutil/issues/1324 * Added error-checking logic for mounting ISOs and also created a wiki page that explains some of the errors. --------- Co-authored-by: KonTy <KonTy@github.com> * Compile Winutil * Custom save targets for MicroWin ISOs (#1346) * Workaround for Explorer freezes Some people have reported that setting the Event Log service to Automatic and starting it can (temporarily) fix Explorer freezes. This change detects whether the next service in the list is "EventLog" and skips it * Allow user to save MicroWin ISOs anywhere Adds a SaveFileDialog component to let the user specify the location of the MicroWin ISO and uses it during creation with oscdimg. (It uses a Process object from System.Diagnostics because I couldn't get it to work with Start-Process) * Removed temporary workaround Removed my version of the workaround in favor of the version from @KonTy (merge PR #1348 first) --------- Co-authored-by: Chris Titus <contact@christitus.com> * Highly anticipated fix for small screens (#1358) * Increase performance during loading. Add a clear button to the search box. Add link and description attributes to the applications JSON. Use the link for linking to the app website. Use the description as a tooltip for each app. Add a clickable link to the website for each application (this took a long time; don't kick me if I got some wrong). Pressing Escape now clears the filter box. Pressing Alt-P prints your PID. * Fix for services that are being stopped * Compile winutil * Adding new Get-LocalizedYesNo based on choice.exe which is faster and more reliable, thank you @dtm-r for implementing it and testing it on English, German, Dutch, French, Italian, Spansich and Russian. Incredible work by @dtm-r, all cridit and props go to him. See this thread for details https://github.com/ChrisTitusTech/winutil/issues/1324 * Added error-checking logic for mounting ISOs and also created a wiki page that explains some of the errors. * Highly anticipated fix for small screen computers --------- Co-authored-by: KonTy <KonTy@github.com> * Compile Winutil * Winutil take a long time to create iso file and goes to sleep, this fixes that issue #1343 (#1371) Co-authored-by: KonTy <KonTy@github.com> * Compile Winutil * Create .gitattributes * Update .gitattributes * add winget ventoy package (#1374) * add winget ventoy package * convert applications.json to utf-8 * update applications.json again * Compile Winutil * Update applications.json fix encoding * Compile Winutil * Fix Encoding and Bad Symbols * Compile Winutil * feat: Add more software choices (#1379) * Compile Winutil * Update configs.Tests.ps1 * Update winutil.Tests.ps1 * Update applications.json * Compile Winutil * Update applications.json * Compile Winutil * Update applications.json * Compile Winutil * fix functions for unit tests * Compile Winutil * Update Invoke-MicroWin-Helper.ps1 * Compile Winutil * fix name WPF Close Button * Update inputXML.xaml * Compile Winutil * my bad that wasnt it * modify unit test for stop on error * Compile Winutil * Update unittests.yaml * Create test * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * Compile Winutil * Make restore points optional, enabled by default (#1380) * Make restore points optional, enabled by default * Tweaks order fix if restorepoint is checked * Compile Winutil * update unit tests * Compile Winutil * Update unittests.yaml * Update unittests.yaml * Update winutil.Tests.ps1 * tests * Compile Winutil * Update unittests.yaml * Update unittests.yaml * Update unittests.yaml * fix unit test * Update winutil.Tests.ps1 * rewrite all pester test for winutil * Compile Winutil * fix handle is invalid error * final unit test --------- Co-authored-by: KonTy <9524513+KonTy@users.noreply.github.com> Co-authored-by: KonTy <KonTy@github.com> Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com> Co-authored-by: CodingWonders <101426328+CodingWonders@users.noreply.github.com> Co-authored-by: Munkk <152475628+munkk01@users.noreply.github.com> Co-authored-by: Kiril Vasilev <Kiril.v92@gmail.com>
This commit is contained in:
@ -1,4 +1,39 @@
|
||||
function Get-LocalizedYesNo {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
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]?
|
||||
# Dutch: [Y,N]?
|
||||
# German: [J,N]?
|
||||
# French: [O,N]?
|
||||
# Spanish: [S,N]?
|
||||
# Italian: [S,N]?
|
||||
# Russian: [Y,N]?
|
||||
|
||||
$line = cmd /c "choice <nul 2>nul"
|
||||
$charactersArray = @()
|
||||
$regexPattern = '([a-zA-Z])'
|
||||
$charactersArray = [regex]::Matches($line, $regexPattern) | ForEach-Object { $_.Groups[1].Value }
|
||||
|
||||
Write-Debug "According to takeown.exe local Yes is $charactersArray[0]"
|
||||
# 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
|
||||
|
@ -1,30 +1,30 @@
|
||||
function Get-WinUtilVariables {
|
||||
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Gets every form object of the provided type
|
||||
|
||||
.OUTPUTS
|
||||
List containing every object that matches the provided type
|
||||
|
||||
#>
|
||||
param (
|
||||
[Parameter()]
|
||||
[ValidateSet("CheckBox", "Button", "ToggleButton")]
|
||||
[string]$Type
|
||||
[string[]]$Type
|
||||
)
|
||||
|
||||
$keys = $sync.keys | Where-Object {$psitem -like "WPF*"}
|
||||
$keys = $sync.keys | Where-Object { $_ -like "WPF*" }
|
||||
|
||||
if($type){
|
||||
if ($Type) {
|
||||
$output = $keys | ForEach-Object {
|
||||
Try{
|
||||
if ($sync["$psitem"].GetType() -like "*$type*"){
|
||||
Try {
|
||||
$objType = $sync["$psitem"].GetType().Name
|
||||
if ($Type -contains $objType) {
|
||||
Write-Output $psitem
|
||||
}
|
||||
}
|
||||
Catch{<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>}
|
||||
Catch {
|
||||
<#I am here so errors don't get outputted for a couple variables that don't have the .GetType() attribute#>
|
||||
}
|
||||
}
|
||||
return $output
|
||||
}
|
||||
|
@ -1,3 +1,20 @@
|
||||
function Invoke-MicroWin-Helper {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
checking unit tests
|
||||
|
||||
.PARAMETER Name
|
||||
no parameters
|
||||
|
||||
.EXAMPLE
|
||||
placeholder
|
||||
|
||||
#>
|
||||
|
||||
}
|
||||
|
||||
|
||||
function Remove-Features([switch] $dumpFeatures = $false, [switch] $keepDefender = $false) {
|
||||
<#
|
||||
|
||||
@ -430,7 +447,7 @@ function New-FirstRun {
|
||||
|
||||
function Stop-UnnecessaryServices
|
||||
{
|
||||
$servicesAuto = @"
|
||||
$servicesToExclude = @(
|
||||
"AudioSrv",
|
||||
"AudioEndpointBuilder",
|
||||
"BFE",
|
||||
@ -493,12 +510,12 @@ function New-FirstRun {
|
||||
"vm3dservice",
|
||||
"webthreatdefusersvc_dc2a4",
|
||||
"wscsvc"
|
||||
"@
|
||||
)
|
||||
|
||||
$allServices = Get-Service | Where-Object { $_.StartType -eq "Automatic" -and $servicesAuto -NotContains $_.Name}
|
||||
foreach($service in $allServices)
|
||||
$runningServices = Get-Service | Where-Object { $servicesToExclude -notcontains $_.Name }
|
||||
foreach($service in $runningServices)
|
||||
{
|
||||
Stop-Service -Name $service.Name -PassThru
|
||||
Stop-Service -Name $service.Name -PassThru
|
||||
Set-Service $service.Name -StartupType Manual
|
||||
"Stopping service $($service.Name)" | Out-File -FilePath c:\windows\LogFirstRun.txt -Append -NoClobber
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
function Set-WinUtilRestorePoint {
|
||||
<#
|
||||
|
||||
.SYNOPSIS
|
||||
Creates a Restore Point
|
||||
|
||||
#>
|
||||
|
||||
# Check if the user has administrative privileges
|
||||
if (-Not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
|
||||
Write-Host "Please run this script as an administrator."
|
||||
return
|
||||
}
|
||||
|
||||
# Check if System Restore is enabled for the main drive
|
||||
try {
|
||||
# Try getting restore points to check if System Restore is enabled
|
||||
Enable-ComputerRestore -Drive "$env:SystemDrive"
|
||||
} catch {
|
||||
Write-Host "An error occurred while enabling System Restore: $_"
|
||||
}
|
||||
|
||||
# Check if the SystemRestorePointCreationFrequency value exists
|
||||
$exists = Get-ItemProperty -path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -name "SystemRestorePointCreationFrequency" -ErrorAction SilentlyContinue
|
||||
if($null -eq $exists){
|
||||
write-host 'Changing system to allow multiple restore points per day'
|
||||
Set-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SystemRestore" -Name "SystemRestorePointCreationFrequency" -Value "0" -Type DWord -Force -ErrorAction Stop | Out-Null
|
||||
}
|
||||
|
||||
# Get all the restore points for the current day
|
||||
$existingRestorePoints = Get-ComputerRestorePoint | Where-Object { $_.CreationTime.Date -eq (Get-Date).Date }
|
||||
|
||||
# Check if there is already a restore point created today
|
||||
if ($existingRestorePoints.Count -eq 0) {
|
||||
$description = "System Restore Point created by WinUtil"
|
||||
|
||||
Checkpoint-Computer -Description $description -RestorePointType "MODIFY_SETTINGS"
|
||||
Write-Host -ForegroundColor Green "System Restore Point Created Successfully"
|
||||
}
|
||||
}
|
@ -55,6 +55,6 @@ function Invoke-WPFButton {
|
||||
"WPFGetInstalledTweaks" {Invoke-WPFGetInstalled -CheckBox "tweaks"}
|
||||
"WPFGetIso" {Invoke-WPFGetIso}
|
||||
"WPFMicrowin" {Invoke-WPFMicrowin}
|
||||
"WPFCloseButton" {Invoke-CloseButton}
|
||||
"WPFCloseButton" {Invoke-WPFCloseButton}
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
function Invoke-CloseButton {
|
||||
function Invoke-WPFCloseButton {
|
||||
|
||||
<#
|
||||
|
||||
|
@ -80,11 +80,19 @@ function Invoke-WPFGetIso {
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Mounting Iso. Please wait."
|
||||
$mountedISO = Mount-DiskImage -PassThru "$filePath"
|
||||
Write-Host "Done mounting Iso $mountedISO"
|
||||
$driveLetter = (Get-Volume -DiskImage $mountedISO).DriveLetter
|
||||
Write-Host "Iso mounted to '$driveLetter'"
|
||||
try {
|
||||
Write-Host "Mounting Iso. Please wait."
|
||||
$mountedISO = Mount-DiskImage -PassThru "$filePath"
|
||||
Write-Host "Done mounting Iso $mountedISO"
|
||||
$driveLetter = (Get-Volume -DiskImage $mountedISO).DriveLetter
|
||||
Write-Host "Iso mounted to '$driveLetter'"
|
||||
} catch {
|
||||
# @ChrisTitusTech please copy this wiki and change the link below to your copy of the wiki
|
||||
Write-Error "Failed to mount the image. Error: $($_.Exception.Message)"
|
||||
Write-Error "This is NOT winutil's problem, your ISO might be corrupt, or there is a problem on the system"
|
||||
Write-Error "Please refer to this wiki for more details https://github.com/KonTy/winutil/wiki/Error-in-Winutil-MicroWin-during-ISO-mounting"
|
||||
return
|
||||
}
|
||||
# storing off values in hidden fields for further steps
|
||||
# there is probably a better way of doing this, I don't have time to figure this out
|
||||
$sync.MicrowinIsoDrive.Text = $driveLetter
|
||||
|
@ -10,7 +10,40 @@ function Invoke-WPFMicrowin {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
# Define the constants for Windows API
|
||||
Add-Type @"
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public class PowerManagement {
|
||||
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||
public static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
|
||||
|
||||
[FlagsAttribute]
|
||||
public enum EXECUTION_STATE : uint {
|
||||
ES_SYSTEM_REQUIRED = 0x00000001,
|
||||
ES_DISPLAY_REQUIRED = 0x00000002,
|
||||
ES_CONTINUOUS = 0x80000000,
|
||||
}
|
||||
}
|
||||
"@
|
||||
|
||||
# Prevent the machine from sleeping
|
||||
[PowerManagement]::SetThreadExecutionState([PowerManagement]::EXECUTION_STATE::ES_CONTINUOUS -bor [PowerManagement]::EXECUTION_STATE::ES_SYSTEM_REQUIRED -bor [PowerManagement]::EXECUTION_STATE::ES_DISPLAY_REQUIRED)
|
||||
|
||||
# Ask the user where to save the file
|
||||
$SaveDialog = New-Object System.Windows.Forms.SaveFileDialog
|
||||
$SaveDialog.InitialDirectory = [Environment]::GetFolderPath('Desktop')
|
||||
$SaveDialog.Filter = "ISO images (*.iso)|*.iso"
|
||||
$SaveDialog.ShowDialog() | Out-Null
|
||||
|
||||
if ($SaveDialog.FileName -eq "") {
|
||||
Write-Host "No file name for the target image was specified"
|
||||
return
|
||||
}
|
||||
|
||||
Write-Host "Target ISO location: $($SaveDialog.FileName)"
|
||||
|
||||
$index = $sync.MicrowinWindowsFlavors.SelectedValue.Split(":")[0].Trim()
|
||||
Write-Host "Index chosen: '$index' from $($sync.MicrowinWindowsFlavors.SelectedValue)"
|
||||
|
||||
@ -107,14 +140,6 @@ function Invoke-WPFMicrowin {
|
||||
Remove-FileOrDirectory -pathToDelete "$($scratchDir)\Windows\SystemApps" -mask "*ParentalControls*" -Directory
|
||||
Write-Host "Removal complete!"
|
||||
|
||||
# *************************** Automation black ***************************
|
||||
# this doesn't work for some reason, this script is not being run at the end of the install
|
||||
# if someone knows how to fix this, feel free to modify
|
||||
New-Item -ItemType Directory -Force -Path $scratchDir\Windows\Setup\Scripts\
|
||||
"wmic cpu get Name > C:\windows\cpu.txt" | Out-File -FilePath "$($scratchDir)\Windows\Setup\Scripts\SetupComplete.cmd" -NoClobber -Append
|
||||
"wmic bios get serialnumber > C:\windows\SerialNumber.txt" | Out-File -FilePath "$($scratchDir)\Windows\Setup\Scripts\SetupComplete.cmd" -NoClobber -Append
|
||||
"devmgmt.msc /s" | Out-File -FilePath "$($scratchDir)\Windows\Setup\Scripts\SetupComplete.cmd" -NoClobber -Append
|
||||
|
||||
Write-Host "Create unattend.xml"
|
||||
New-Unattend
|
||||
Write-Host "Done Create unattend.xml"
|
||||
@ -255,7 +280,7 @@ function Invoke-WPFMicrowin {
|
||||
|
||||
if (-not (Test-Path -Path "$mountDir\sources\install.wim"))
|
||||
{
|
||||
Write-Error "Somethig went wrong and '$mountDir\sources\install.wim' doesn't exist. Please report this bug to the devs"
|
||||
Write-Error "Something went wrong and '$mountDir\sources\install.wim' doesn't exist. Please report this bug to the devs"
|
||||
return
|
||||
}
|
||||
Write-Host "Windows image completed. Continuing with boot.wim."
|
||||
@ -323,13 +348,23 @@ function Invoke-WPFMicrowin {
|
||||
|
||||
Write-Host "[INFO] Using oscdimg.exe from: $oscdimgPath"
|
||||
#& oscdimg.exe -m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin $mountDir $env:temp\microwin.iso
|
||||
Start-Process -FilePath $oscdimgPath -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin $mountDir $env:temp\microwin.iso" -NoNewWindow -Wait
|
||||
#Start-Process -FilePath $oscdimgPath -ArgumentList "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin $mountDir $env:temp\microwin.iso" -NoNewWindow -Wait
|
||||
#Start-Process -FilePath $oscdimgPath -ArgumentList '-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin $mountDir `"$($SaveDialog.FileName)`"' -NoNewWindow -Wait
|
||||
$oscdimgProc = New-Object System.Diagnostics.Process
|
||||
$oscdimgProc.StartInfo.FileName = $oscdimgPath
|
||||
$oscdimgProc.StartInfo.Arguments = "-m -o -u2 -udfver102 -bootdata:2#p0,e,b$mountDir\boot\etfsboot.com#pEF,e,b$mountDir\efi\microsoft\boot\efisys.bin $mountDir `"$($SaveDialog.FileName)`""
|
||||
$oscdimgProc.StartInfo.CreateNoWindow = $True
|
||||
$oscdimgProc.StartInfo.WindowStyle = "Hidden"
|
||||
$oscdimgProc.StartInfo.UseShellExecute = $False
|
||||
$oscdimgProc.Start()
|
||||
$oscdimgProc.WaitForExit()
|
||||
|
||||
if ($copyToUSB)
|
||||
{
|
||||
Write-Host "Copying microwin.iso to the USB drive"
|
||||
Copy-ToUSB("$env:temp\microwin.iso")
|
||||
Write-Host "Done Copying microwin.iso to USB drive!"
|
||||
Write-Host "Copying target ISO to the USB drive"
|
||||
#Copy-ToUSB("$env:temp\microwin.iso")
|
||||
Copy-ToUSB("$($SaveDialog.FileName)")
|
||||
if ($?) { Write-Host "Done Copying target ISO to USB drive!" } else { Write-Host "ISO copy failed." }
|
||||
}
|
||||
|
||||
Write-Host " _____ "
|
||||
@ -344,18 +379,20 @@ function Invoke-WPFMicrowin {
|
||||
Write-Host "`n`nPerforming Cleanup..."
|
||||
Remove-Item -Recurse -Force "$($scratchDir)"
|
||||
Remove-Item -Recurse -Force "$($mountDir)"
|
||||
$msg = "Done. ISO image is located here: $env:temp\microwin.iso"
|
||||
#$msg = "Done. ISO image is located here: $env:temp\microwin.iso"
|
||||
$msg = "Done. ISO image is located here: $($SaveDialog.FileName)"
|
||||
Write-Host $msg
|
||||
[System.Windows.MessageBox]::Show($msg, "Winutil", [System.Windows.MessageBoxButton]::OK, [System.Windows.MessageBoxImage]::Information)
|
||||
} 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 = "$env:temp\microwin.iso"
|
||||
$sync.MicrowinFinalIsoLocation.Text = "$($SaveDialog.FileName)"
|
||||
# Allow the machine to sleep again (optional)
|
||||
[PowerManagement]::SetThreadExecutionState(0)
|
||||
$sync.ProcessRunning = $false
|
||||
}
|
||||
}
|
@ -27,10 +27,16 @@ function Invoke-WPFtweaksbutton {
|
||||
|
||||
$sync.ProcessRunning = $true
|
||||
|
||||
Set-WinUtilRestorePoint
|
||||
# Executes first if selected
|
||||
if ("WPFEssTweaksRestorePoint" -in $Tweaks) {
|
||||
Invoke-WinUtilTweaks "WPFEssTweaksRestorePoint"
|
||||
}
|
||||
|
||||
Foreach ($tweak in $tweaks){
|
||||
Invoke-WinUtilTweaks $tweak
|
||||
# Execute other selected tweaks
|
||||
foreach ($tweak in $tweaks) {
|
||||
if ($tweak -ne "WPFEssTweaksRestorePoint") {
|
||||
Invoke-WinUtilTweaks $tweak
|
||||
}
|
||||
}
|
||||
|
||||
$sync.ProcessRunning = $false
|
||||
|
Reference in New Issue
Block a user