How to Block .exe Execution from Removable Media in Windows Environments Using Group Policy


2 views

Administrators frequently encounter security risks when users execute untrusted applications from USB drives or other removable media. The fundamental problem lies in Windows' default behavior of assigning dynamic drive letters to removable storage, making systematic blocking challenging.

For Server 2008 environments (without AppLocker), the most effective solution involves Software Restriction Policies:

:: PowerShell snippet to enumerate potential removable drive letters
Get-WmiObject Win32_LogicalDisk | Where-Object {$_.DriveType -eq 2} | Select-Object DeviceID

Create these path rules in gpedit.msc under:

User Configuration > Windows Settings > Security Settings > Software Restriction Policies > Additional Rules

Example rules to add:

Path: %HOMEDRIVE%\*.exe
Security Level: Unrestricted

Path: ?:\*.exe
Security Level: Disallowed

For environments where GPO isn't feasible, implement this registry modification:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows\RemovableStorageDevices]
"Deny_Execute"=dword:00000001

After implementation, verify the restrictions:

  1. Insert test USB with known safe .exe
  2. Attempt execution while monitoring Event Viewer logs
  3. Check Application log for policy enforcement events (Event ID 865)

For large deployments, combine with these complementary measures:

  • Device Control Policies (to whitelist authorized USB devices)
  • SRP hash rules for critical system directories
  • Regular GPO refresh cycles (gpupdate /force)

Administrators often face security risks when users execute untrusted .exe files from USB drives or other removable storage. While modern systems offer AppLocker, legacy environments like Windows Server 2008 require alternative approaches.

For Server 2008, the most reliable method is creating path rules in Group Policy:

1. Open gpedit.msc
2. Navigate to:
   User Configuration > Windows Settings > Security Settings > 
   Software Restriction Policies > Additional Rules
3. Right-click → New Path Rule
4. For each potential drive letter (E: to L:):
   - Path: E:\*.exe
   - Security Level: Disallowed

Consider implementing these registry tweaks via GPO:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control]
"StorageDevicePolicies"=dword:00000001

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies]
"WriteProtect"=dword:00000001

For additional protection, deploy this PowerShell monitoring script:

# PowerShell removable media monitor
$watcher = New-Object System.IO.FileSystemWatcher
$watcher.Path = "E:\","F:\","G:\","H:\","I:\","J:\","K:\","L:\"
$watcher.Filter = "*.exe"
$watcher.IncludeSubdirectories = $true
$watcher.EnableRaisingEvents = $true

$action = {
    $path = $Event.SourceEventArgs.FullPath
    Stop-Process -Name $path.Split('\')[-1].Replace('.exe','') -Force
    Write-EventLog -LogName Application -Source "Security" -EntryType Warning -EventId 1001 -Message "Blocked EXE execution from $path"
}

Register-ObjectEvent $watcher "Created" -Action $action

For environments where Group Policy isn't available:

  • Implement SRP (Software Restriction Policies) with hash rules for known malicious files
  • Use startup scripts to modify NTFS permissions on removable drives
  • Consider third-party tools like Deep Freeze for public workstations