From 8eee1f32ab17436a6fc835ed69c2fbd7da1a67f4 Mon Sep 17 00:00:00 2001 From: Lightemerald Date: Mon, 23 Oct 2023 12:45:12 +0000 Subject: [PATCH] Update setupScriptInfo.ps1 --- setupScriptInfo.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setupScriptInfo.ps1 b/setupScriptInfo.ps1 index cfc53aa..201e6ae 100644 --- a/setupScriptInfo.ps1 +++ b/setupScriptInfo.ps1 @@ -120,13 +120,11 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) { # Add entries to DisallowRun for cmd.exe and powershell.exe $DisallowRunKeyPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" $DisallowRunValueName = "DisallowRun" - SetRegistry -regpath $DisallowRunKeyPath -regproperty $DisallowRunValueName - $DisallowRunPath = "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun" if (-not (Test-Path -Path "Registry::$DisallowRunPath" -PathType Container)) { New-Item -Path $DisallowRunPath -Force - Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 } + Set-ItemProperty -Path "$UserHKUPath\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -Name "DisallowRun" -Value 1 $applications = @("cmd.exe", "powershell.exe", "powershell_ise.exe") Get-ItemProperty -Path $DisallowRunPath | ForEach-Object { Remove-ItemProperty -Path $DisallowRunPath -Name $_.PSObject.Properties.Name -ErrorAction SilentlyContinue @@ -134,7 +132,7 @@ if ($UserSID -ne $null -and $UserHKUPath -ne $null) { foreach ($valueName in $applications) { New-ItemProperty -Path $DisallowRunPath -Name $valueName -Value $valueName -PropertyType String } - REG UNLOAD HKEY_USERS\$UserSID -ErrorAction SilentlyContinue + REG UNLOAD HKEY_USERS\$UserSID } else { Write-Host "Unable to get the user's HKU registry." }