Skip to content

Commit

Permalink
Create block_dotnet.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
harishsg993010 authored Jan 10, 2023
1 parent 95d4c11 commit 4305589
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions block_dotnet.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Define the list of executables to block
$executables = @("csc.exe", "DataSvcUtil.exe", "Ieexec.exe", "Ilasm.exe", "InstallUtil.exe", "Jsc.exe", "Microsoft.Workflow.Compiler.exe", "MSBuild.exe","dotnet.exe")

# Set the path to the .NET Framework folder
$dotnetPath = "C:\Windows\Microsoft.NET\Framework\"

# Loop through the list of executables
foreach ($executable in $executables) {

# Construct the path to the executable
$path = Join-Path -Path $dotnetPath -ChildPath $executable

# Check if the file exists
if (Test-Path -Path $path) {

#Block the executable by adding a new rule to the Group Policy Editor
New-GPRegistryValue -Name "Restrict_Execution_Of_Certain_Windows_Application" -Key "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer" -ValueName $executable -Type String -Value "0"
}
}

0 comments on commit 4305589

Please sign in to comment.