From 15e567ccff7664de96af022d049bff426a01f655 Mon Sep 17 00:00:00 2001 From: he3als <65787561+he3als@users.noreply.github.com> Date: Fri, 6 Sep 2024 20:57:10 +0100 Subject: [PATCH] feat(BACKUP): optimise it --- src/playbook/Executables/BACKUP.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/playbook/Executables/BACKUP.ps1 b/src/playbook/Executables/BACKUP.ps1 index f6e2c1a543..3a89c3691f 100644 --- a/src/playbook/Executables/BACKUP.ps1 +++ b/src/playbook/Executables/BACKUP.ps1 @@ -5,15 +5,18 @@ param ( if (Test-Path $FilePath) { exit } -Add-Content -Path $FilePath -Value "Windows Registry Editor Version 5.00" +$content = [System.Collections.Generic.List[string]]::new() +$content.Add("Windows Registry Editor Version 5.00") Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services" | ForEach-Object { if ((Get-ItemProperty $_.PSPath).PSObject.Properties.Name -contains "Start") { $startValue = (Get-ItemProperty -Path $_.PSPath -Name "Start").Start for ($c = 0; $c -le 4; $c++) { if ($startValue -eq "0x$c") { - Add-Content -Path $FilePath -Value ("`n" + "[" + $_.Name + "]") - Add-Content -Path $FilePath -Value ("`"Start`"=dword:0000000$c") + $content.Add("`n[$($_.Name)]") + $content.Add('"Start"=dword:0000000' + $c) } } } } + +Set-Content -Path $FilePath -Value $content -Force -Encoding UTF8 \ No newline at end of file