# REMOVE HKCU File Type Association
# in addition to OEMDefaultAssociation.xml
Function RegACL-Reset
{
$hkey = 2147483649
$reg = [wmiclass]"root\default:StdRegProv"
$ace = $reg.GetSecurityDescriptor($hkey,$hsubkey).Descriptor.DACL
$reg.psbase.Scope.Options.EnablePrivileges = $true
$sd = ([WMIClass] "Win32_SecurityDescriptor").CreateInstance()
$sd.ControlFlags = 0x0004
for($i=0;$i -lt $ace.length;$i++)
{
if($ace[$i].AceType -ne 1)
{
$SD.dacl += $ace[$i]
}
}
$reg.SetSecurityDescriptor($hkey,$hsubkey,$sd)
}
# .XML - Remove user defined .XML file type association
$testreg = Test-Path -Path HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.xml
if ($testreg -eq $true){
#$hsubkey = "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.xml\UserChoice"
RegACL-Reset -hsubkey "Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.xml\UserChoice"
Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.xml" -Force -Recurse
Author Comment
by:Olivier MarchettaAuthor Comment
by:Olivier MarchettaAuthor Comment
by:Olivier MarchettaComment
by:McKnifeAuthor Comment
by:Olivier MarchettaAuthor Comment
by:Olivier MarchettaComment
by:McKnifeLimitationsJust confirmed this to be true on Win10 1803 pro.
1 The end user machine needs to be domain-joined for this method to work.
Author Comment
by:Olivier MarchettaAuthor Comment
by:Olivier MarchettaComment
by:Lee W, MVPThe Original Tech Community