Hi Gays,
I want to use powershell to delete registry key, but failed.
this is my code
Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.ics\UserChoice" -Force
and it shows `Remove-Item : Cannot delete a subkey tree because the subkey does not exist.
At line:1 char:1
- Remove-Item -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Ex …
-
+ CategoryInfo : WriteError: (HKEY_CURRENT_US....ics\UserChoice:String) [Remove-Item], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.RemoveItemCommand`
and I find C# .net can do it.
internal class Program
{
static void Main(string[] args)
{
RegistryKey FileExts = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts");
RegistryKey hdr = FileExts.OpenSubKey(".ics", true);
foreach (String key in hdr.GetSubKeyNames())
hdr.DeleteSubKey(key);
hdr.Close();
}
}
and I want to use it in powershell
then I use this $file=[Microsoft.Win32.Registry]::CurrentUser.CreateSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\FileExts\") $hdr=$file.OpenSubKey(".ics",$true) $hdr
but nothing find in powershell.
does any body know what shoud I do?