Несколько ip адресов алиасов на одном сетевом интерфейсе в windows

I’m trying to disable the annoying context menu in windows explorer using powershell.

reg add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve

This works great, but I cannot get this to work using powershell’s own registry functions. I’ve tried a variety of ways.

$LP2 = "HKLM:\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32\"
Set-ItemProperty -Path $LP2 -Type String -Value "" -Force | Out-Null
# FAILS
Set-ItemProperty -Path $LP2 -Type String -Value ([byte[]]::new(0)) -Force | Out-Null
# FAILS
# And finally
$LP2 = "HKLM:\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\"
Set-ItemProperty -Path $LP2 -Name "InprocServer32" -Type String -Value ([byte[]]::new(0)) -Force | Out-Null
# Results in the permission error:
# Set-ItemProperty: Requested registry access is not allowed.

What’s going on, and what is the equivalent to the reg add above?


$LP2 = "HKLM:\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32"
Set-ItemProperty -Path $LP2 -Name '(default)' -Type String -Value '' -Force | Out-Null
# Set-ItemProperty: Requested registry access is not allowed.

not2qubit's user avatar

9 gold badges106 silver badges147 bronze badges

Instead of trying to set a registry value to $null or an empty string using Set-ItemProperty, why not use Clear-ItemProperty instead?

$LP2 = 'HKLM:\SOFTWARE\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32'
Clear-ItemProperty -Path $LP2 -Name '(Default)'

Theo's user avatar

8 gold badges26 silver badges43 bronze badges

  1. The statement below (marked with strike-through), concerning the REG.EXE command not working, was incorrect. I had a copy paste error when I tried to test the command.
  2. This answer does not fix, bypass, or resolve the root issue of the question being asked. To solve the root problem, it will likely require taking ownership of the desired registry key, which will require an answer similar to this.
  3. I’m keeping this answer here since it is still a valid, but more complex, method for creating an empty default value in a registry key.

The Microsoft.Win32 way:

Registry is, without question, a “There’s more than one way to skin a cat” type of thing. Due to the increased complexity of this answer, I present this as a “If all else fails, do this” option.

using namespace Microsoft.Win32
try { $obk = [RegistryKey]::OpenBaseKey([RegistryHive]::CurrentUser, [RegistryView]::Registry64) $rwSubKey = $obk.CreateSubKey('Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32') if ($null -ne $rwSubKey) { $ValueName = '' $ValueData = '' $rwSubKey.SetValue($ValueName, $ValueData, [RegistryValueKind]::String) }
}
catch { Write-Error "An error occurred: $_"
}
finally { if ($null -ne $rwSubKey) { $rwSubKey.Dispose() }
}

Creates a new subkey or opens an existing subkey for write access.

  1. CreateSubKey comes in 7 flavors, so if you continue to have problems, there may still be a solution.
  2. In the experiments I did, using [RegistryView]::Registry32 reports no errors, but does NOT create the desired registry value in the desired location. Instead, it creates it here:
  • SOFTWARE\Classes\WOW6432Node\CLSID{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32
  1. Successfully tested in both PowerShell 5.1 and 7.4.2.
:/>  На сколько процентов влияют nslookup type any? ( )

Darin's user avatar

1 gold badge13 silver badges18 bronze badges

Try New-Item.
It resets the key if it already exists when bound with the Force switch parameter. So all the subsequent name-value pairs will be deleted.

New-Item -Path $LP2 -Force

Fabrice SANGA's user avatar