win-vbox-net-uninstall.ps1 revision 2b114c590cf5a19f8047cd7bde9c7e5ae00aa22b
306N/A $yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yes_text
306N/A $no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $no_text
306N/A $options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
306N/A $result = $host.ui.PromptForChoice($title, $message, $options, 0)
306N/A $ghostcon = @(Get-ChildItem ($reg_key) | Where-Object { !$connections.ContainsKey($_.PSChildName) } )
306N/A if ($ghostcon.count -eq 0) {
493N/A 0 {$ghostcon.GetEnumerator() | ForEach-Object { Remove-Item -Path $_ -Recurse }}
306N/AGet-Item ".\HKLM\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0*" | `
636N/A if (Test-Path ("HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" + $prop.NetCfgInstanceId + "\Connection")) {
636N/A $conn = (Get-ItemProperty ("HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" + $prop.NetCfgInstanceId + "\Connection"))
636N/A if ($iftypes.ContainsKey($iftype)) {
636N/A $iftypes[$iftype] = $iftypes[$iftype] + [Math]::pow(2,$prop.NetLuidIndex)
715N/A $iftypes[$iftype] = [Math]::pow(2,$prop.NetLuidIndex)
Write-Host $prop.NetCfgInstanceId $conn.Name "|" $prop."*IfType" $prop.NetLuidIndex $prop.DriverDesc
# Someday we may want to process other types than Ethernet as well: $iftypes.GetEnumerator() | ForEach-Object {
$actualmask = (Get-ItemProperty -Path "HKLM\SYSTEM\CurrentControlSet\Services\NDIS\IfTypes\6" -Name "IfUsedNetLuidIndices").IfUsedNetLuidIndices
for ($ci = 0; $ci -lt $correctmask.Length; $ci++) {
if ($ai -lt $actualmask.Length) {
Write-Host "DEBUG: " $correctmask[$ci].ToString("X2") " == " $aval.ToString("X2")
Write-Host "DEBUG: " $correctmask[$ci].ToString("X2") " != " $aval.ToString("X2")
if ($ai -lt $actualmask.Length) {
for (; $ai -lt $actualmask.Length; $ai++) {
Write-Host "Current mask is " ($actualmask|foreach {$_.ToString("X2")}) ", while it should be" ($correctmask|foreach {$_.ToString("X2")})
Set-ItemProperty -Path "HKLM\SYSTEM\CurrentControlSet\Services\NDIS\IfTypes\6" -Name "IfUsedNetLuidIndices" -Value $correctmask -Type Binary -Confirm
Set-ItemProperty -Path "HKLM\SYSTEM\CurrentControlSet\Services\NDIS\IfTypes\6" -Name "IfUsedNetLuidIndices" -Value $correctmask -Type Binary
$ghostcon = @(Get-ChildItem ("HKLM\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}") | Where-Object { !$connections.ContainsKey($_.PSChildName) -and $_.PSChildName -ne "Descriptions" } )
$ghostcon.GetEnumerator() | ForEach-Object {
if ($prop.PnPInstanceId -eq $null) {
Write-Host "WARNING! PnPInstanceId does not exist for" $_.PSChildName
} elseif (!($prop.PnPInstanceId.ToString() -match "SUN_VBOXNETFLTMP")) {
Write-Host "WARNING! PnPInstanceId (" $prop.PnPInstanceId.ToString() ") does not match ROOT\SUN_VBOXNETFLTMP for" $_.PSChildName
if ($prop.Name -eq $null) {
Write-Host "WARNING! Name does not exist for" $_.PSChildName
Write-Host $_.PSChildName -nonewline
Write-Host $prop.Name
DeleteUnmatchingKeys "Delete WFPLWFS Parameter Keys (Adapter subkey)" "HKLM\SYSTEM\CurrentControlSet\Services\WFPLWFS\Parameters\Adapters"
DeleteUnmatchingKeys "Delete WFPLWFS Parameter Keys (NdisAdapter subkey)" "HKLM\SYSTEM\CurrentControlSet\Services\WFPLWFS\Parameters\NdisAdapters"
DeleteUnmatchingKeys "Delete Psched Parameter Keys (Adapter subkey)" "HKLM\SYSTEM\CurrentControlSet\Services\Psched\Parameters\Adapters"
DeleteUnmatchingKeys "Delete Psched Parameter Keys (NdisAdapter subkey)" "HKLM\SYSTEM\CurrentControlSet\Services\Psched\Parameters\NdisAdapters"
$nsi_obsolete = New-Object System.Collections.ArrayList
$guid = New-Object -TypeName System.Guid -ArgumentList (,$guid_bytes)
$guid_string = $guid.ToString("B").ToUpper()
if ($connections.ContainsKey($guid_string)) {
[void] $nsi_obsolete.Add($_)
0 {$nsi_obsolete.GetEnumerator() | ForEach-Object { Remove-ItemProperty -Path $nsi_path -Name $_ }}