Virtualbox on Windows 8 Host - Poweshell Code to Fix Resume from Standby Network Issue

I’ve always been a big fan of Vir­tu­al­box.  It has some of the best tools for con­vert­ing images between dif­fer­ent hyper­vi­sors and is a leader in its sup­port for dif­fer­ent con­fig­u­ra­tions.  Vir­tu­al­box is a great option for test­ing out new or dif­fer­ent OS’s and con­fig­u­ra­tions.  I don’t have to run a crip­pled hyper­vi­sor on my sys­tem or run some tri­al­ware just to try the lat­est bits.

Microsoft made a lot of changes to the Win­dows 8 net­work stack.  One of the more obvi­ous is the speed in which net­work con­nec­tions resume from sleep or stand­by.  Unfor­tu­nate­ly, since run­ning Vir­tu­al­box on the Dev Pre­view and on the Final Release, a bug in the Vir­tu­al­box Bridged Adapter breaks net­work con­nec­tiv­i­ty.  Below are a few ways to work around this issue.  You can find more at the bug­traq I sub­mit­ted to Ora­cle here: https://www.virtualbox.org/ticket/10317.

Option 1: Disable Virtualbox Bridged Adapter

For me, NAT adapters had too many draw backs to my test­ing and use.  But, this is how I have been run­ning until I got off my lau­rels and auto­mat­ed the disable/enable rou­tine out­lined in option 3.

  1. In Win­dows, go to: Con­trol Pan­el­Net­work and Inter­net­Net­work Con­nec­tions
  2. Right click the affect­ed/in-use net­work adapter and select prop­er­ties
  3. In the items list, uncheck the Vir­tu­al­Box Bridged Net­work Adapter
  4. Hit OK and you should be all set

Option 2: Disable/Re-Enable Adapters After Resuming

Doing this man­u­al­ly is extreme­ly labo­ri­ous and usu­al­ly ends up with you giv­ing up on bridged adapters.  Either select option 1 or 3.  But, it may save you if you just installed Vir­tu­al­box and haven’t had the chance to imple­ment option 1 or 3.

  1. In Win­dows, go to: Con­trol Pan­el­Net­work and Inter­net­Net­work Con­nec­tions
  2. Right click the affect­ed/in-use net­work adapter and select dis­able
  3. Right click the affect­ed/in-use net­work adapter and select enable

Option 3: Automate Option 2

The fol­low­ing steps will cre­ate a task that will auto­mat­i­cal­ly dis­able and reen­able you net­work adapters upon resume.  This will slow down recon­nects but will allow the use of the Vir­tu­al­Box Bridged Net­work Adapter.

  1. Cre­ate and save a script with the fol­low­ing com­mand:
    1. gwmi Win32_NetworkAdapter -EnableAll­Priv­i­leges | ? { $_.PhysicalAdapter -and $_.NetEnabled } | % { $_.Disable(); $_.Enable() }
  2. Open the Event Log and go the the Sys­tem Event Log
  3. Look/Search/Filter for Event ID 1, Source Pow­er-Trou­bleshoot­er
  4. Right click on Event and select “Attach Task to this Event”
  5. In the Action sec­tion, under Program/script, enter: powershell.exe
  6. In the Argu­ments sec­tion, enter: c:scriptsvirtualbox-hack.ps1
    1. Make sure the path and name match­es what you named your script in step 1
  7. On the fin­ish screen, check the box “Open the Prop­er­ties dia­glog…” and press OK
  8. On the Gen­er­al tab of the task prop­er­ties, select:
    1. Run whether user is logged in or not”
    2. Run with high­est priv­ilges”
  9. Select OK. It should prompt you for cre­den­tials. Enter the cre­den­tials and you are done.