Skip to content

Commit

Permalink
feat(BACKUP): optimise it
Browse files Browse the repository at this point in the history
  • Loading branch information
he3als committed Sep 6, 2024
1 parent 01fde65 commit 15e567c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/playbook/Executables/BACKUP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 15e567c

Please sign in to comment.