From 337b2a9c864de60cb8e8cf79f32be7a34b549ca3 Mon Sep 17 00:00:00 2001 From: poslop Date: Wed, 14 Jan 2026 10:48:35 -0600 Subject: [PATCH] interanl flag detection --- RemoveHKeyPrinters.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/RemoveHKeyPrinters.ps1 b/RemoveHKeyPrinters.ps1 index d208531..a2639ab 100644 --- a/RemoveHKeyPrinters.ps1 +++ b/RemoveHKeyPrinters.ps1 @@ -1,3 +1,10 @@ +$flagFile = "C:\ProgramData\PrinterHKeyClean\v1.flag" + +if (Test-Path $flagFile) { + Write-Host "Script has already run. Exiting." + exit +} + $profileListKey = 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList' $sids = Get-ChildItem $profileListKey @@ -48,4 +55,4 @@ net start spooler gpupdate /force -New-Item -Path "C:\ProgramData\PrinterHKeyClean\v1.flag" -ItemType File -Force +New-Item -Path $flagFile -ItemType File -Force