Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Define the path to jscript.dll for both 32-bit and 64-bit versions
- $syswow64Jscript = Join-Path -Path $env:windir -ChildPath "SysWOW64\jscript.dll"
- $system32Jscript = Join-Path -Path $env:windir -ChildPath "System32\jscript.dll"
- # Function to take ownership and deny permissions
- function Set-FileSecurity {
- param (
- [string]$filePath
- )
- # Take ownership
- $newOwner = [System.Security.Principal.NTAccount]"Administrators"
- $acl = Get-Acl -Path $filePath
- $acl.SetOwner($newOwner)
- Set-Acl -Path $filePath -AclObject $acl
- # Deny permissions to everyone
- $accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule("Everyone", "FullControl", "None", "None", "Deny")
- $acl.SetAccessRule($accessRule)
- Set-Acl -Path $filePath -AclObject $acl
- }
- # Apply to 64-bit Internet Explorer files
- if (Test-Path -Path $syswow64Jscript) {
- Set-FileSecurity -filePath $syswow64Jscript
- }
- if (Test-Path -Path $system32Jscript) {
- Set-FileSecurity -filePath $system32Jscript
- }
- # Apply to 32-bit Internet Explorer file (This will be the same as one of the above, depending on the system architecture)
- Set-FileSecurity -filePath $system32Jscript
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement