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