'OERN to prevent termination on non-collection Sub-Keys on error resume next 'Constants and unchanging variables const HKEY_LOCAL_MACHINE = &H80000002 dim objShell Set objShell = CreateObject("WScript.Shell") strComputer = "." 'Set StdOut = WScript.StdOut Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") 'Enumerate Class Sub-Keys strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}" oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys Set Updated=False 'Enumerate Values for each Sub-Key For Each subkey In arrSubKeys strKeyPath = "SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & subkey oReg.EnumValues HKEY_LOCAL_MACHINE, strKeyPath, arrValueNames, arrValueTypes 'Look for DriverDesc value "sun_vboxnetadp" strValueName = "DriverDesc" oReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue If strValue = "VirtualBox Host-Only Ethernet Adapter" Then 'Upon finding String Value "sun_vboxnetadp" Get Data for "*NdisDeviceType" DWORD Value strValueName = "*NdisDeviceType" oReg.GetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue 'Check to see if DWORD data for "*NdisDeviceType" does not exist, is 0, or greater than 1 If IsNull(dwValue) Or dwValue = 0 Or dwValue > 1 Then 'If DWORD data does not exist, is 0, or is greater than 1, Set "*NdisDeviceType" Value to "1" dwValue = 000000001 oReg.SetDWORDValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue 'Get Data for "NetCfgInstanceId" String Value strInstanceId = "NetCfgInstanceId" oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strInstanceId,strValue 'Get String Value for Network adapter Name strKeyPath = "SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\" & strValue & "\Connection" strName = "Name" oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strName,strValue 'Reset Network adapter Set oWmi=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\CIMV2") Set oNic=oWmi.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID = '" & strValue & "'") If oNic Is Not Nothing Then If oNic.ItemIndex(0).Disable() = 0 Then oNic.ItemIndex(0).Enable() Updated = True End If End If End If End If Next If Updated Then Set objShell = CreateObject("Wscript.Shell") objShell.run _ "powershell.exe -sta -nologo -command """ & _ "[void] [System.Reflection.Assembly]::LoadWithPartialName(\""System.Windows.Forms\"");" & _ "[void] [System.Reflection.Assembly]::LoadWithPartialName(\""System.Drawing\"");" & _ "$path = Get-Process -id $pid | Select-Object -ExpandProperty Path;" & _ "$balloon = new-object system.windows.forms.notifyicon;" & _ "$balloon.icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path);" & _ "$balloon.visible = $true;" & _ "$balloon.showballoontip(" & _ " 5," & _ " \""VirtualBox Networking\""," & _ " \""Updated VirtualBox host-only adapters\""," & _ " [system.windows.forms.tooltipicon]::Info" & _ ");" & _ "$null = Register-ObjectEvent $balloon BalloonTipClicked -SourceIdentifier event_BalloonTipClicked;" & _ "$null = Register-ObjectEvent $balloon BalloonTipClosed -SourceIdentifier event_BalloonTipClosed;" & _ "$null = Wait-Event event_BalloonTip*;" & _ "$balloon.Dispose();" & _ "Unregister-Event -SourceIdentifier event_BalloonTip* -Force;" & _ "Remove-Event event_BalloonTip*;" & _ """", 0 End If