add undoscript feature + implement it on every tweaks
added undoscript feature
.
We would want to update every tweak with an InvokeScript to have an undo script as well. Otherwise we will start seeing error messages.
Also I would try and do something like this instead of putting the undo tweaks inside the beginning section
if($undo){
$Values = @{
Registry = "OriginalValue"
ScheduledTask = "OriginalState"
Service = "OriginalType"
script = "UndoScript"
}
}
Else{
$Values = @{
Registry = "Value"
ScheduledTask = "State"
Service = "StartupType"
script = "InvokeScript"
}
}
if($sync.configs.tweaks.$CheckBox.$script){
$sync.configs.tweaks.$CheckBox.UndoScript | ForEach-Object {
$Scriptblock = [scriptblock]::Create($psitem)
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
}
}
@DeveloperDurp list of tweaks that have an InvokeScript. I will add undo script for these tweaks.
- [ ] WPFEssTweaksTele
- [x] WPFMiscTweaksDisplay
- [ ] WPFEssTweaksDeBloat
- [x] WPFEssTweaksStorage
- [x] WPFEssTweaksRemoveEdge
- [x] WPFMiscTweaksRightClickMenu
- [x] WPFEssTweaksRemoveCortana
@ChrisTitusTech this pr is good to merge. WPFEssTweaksTele and WPFEssTweaksDeBloat are both remaining for undo script I will make another pr for that after doing some testing.
Can you cleanup Invoke-WinUtilTweaks.ps1it still has the 2 if statements for InvokeScript and UndoScript and is in the wrong spot in the script.
Felt this is relevant, undo does not work for the "run OOShutup" option. Search breaks for local installations with winutil.
The interesting part is OOShutup breaking search is inconsistent. I've done a few tests on clean windows 10 installs and most of the time it breaks. Sometimes it does not.
See #569
Can you cleanup Invoke-WinUtilTweaks.ps1it still has the 2 if statements for InvokeScript and UndoScript and is in the wrong spot in the script.
can you explain how to implement that? because I tested previous code you share and it didn't work
for each tweak, we have to use like this?
"WPFMiscTweaksRightClickMenu": {
"Script": [
"InvokeScript" : "New-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Name \"InprocServer32\" -force -value \"\" "
"UndoScript" : "
Remove-Item -Path \"HKCU:\\Software\\Classes\\CLSID\\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\" -Recurse -Confirm:$false -Force
Write-Host Restart Needed for change
"
]
Try
function Invoke-WinUtilTweaks {
<#
.DESCRIPTION
This function converts all the values from the tweaks.json and routes them to the appropriate function
#>
param(
$CheckBox,
$undo = $false
)
if($undo){
$Values = @{
Registry = "OriginalValue"
ScheduledTask = "OriginalState"
Service = "OriginalType"
ScriptType = "UndoScript"
}
}
Else{
$Values = @{
Registry = "Value"
ScheduledTask = "State"
Service = "StartupType"
ScriptType = "InvokeScript"
}
}
if($sync.configs.tweaks.$CheckBox.ScheduledTask){
$sync.configs.tweaks.$CheckBox.ScheduledTask | ForEach-Object {
Set-WinUtilScheduledTask -Name $psitem.Name -State $psitem.$($values.ScheduledTask)
}
}
if($sync.configs.tweaks.$CheckBox.service){
$sync.configs.tweaks.$CheckBox.service | ForEach-Object {
Set-WinUtilService -Name $psitem.Name -StartupType $psitem.$($values.Service)
}
}
if($sync.configs.tweaks.$CheckBox.registry){
$sync.configs.tweaks.$CheckBox.registry | ForEach-Object {
Set-WinUtilRegistry -Name $psitem.Name -Path $psitem.Path -Type $psitem.Type -Value $psitem.$($values.registry)
}
}
if($sync.configs.tweaks.$CheckBox.$($values.ScriptType)){
$sync.configs.tweaks.$CheckBox.$($values.ScriptType) | ForEach-Object {
$Scriptblock = [scriptblock]::Create($psitem)
Invoke-WinUtilScript -ScriptBlock $scriptblock -Name $CheckBox
}
}
if(!$undo){
if($sync.configs.tweaks.$CheckBox.appx){
$sync.configs.tweaks.$CheckBox.appx | ForEach-Object {
Remove-WinUtilAPPX -Name $psitem
}
}
}
}
Edit: had undoscript in the wrong section
for me it still not work give lots of error like this
That means one of your config files is broken
yeah now it works understood the implementation awesome work @DeveloperDurp . Thanks for helping.
@ChrisTitusTech good to merge.
Awesome, Thanks for all the hard work @padsalatushal