Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
"Replug" the cable of running VirtualBox VM (network freeze in guest VM after host windows hybernate - awake)
@echo off
set VboxManageEXE="%VBOX_MSI_INSTALL_PATH%\VBoxManage.exe"
set ListRunningVMS=%VboxManageEXE% list runningvms
for /f tokens^=2^,4^ delims^=^" %%p in ('%ListRunningVMS%') do (
echo "%%p"
%VBoxManageEXE% controlvm %%p setlinkstate1 off
%VBoxManageEXE% controlvm %%p setlinkstate1 on
)
@filimonov
Copy link
Author

filimonov commented Nov 25, 2018

Related to

Generally it gets the list of running machines, and after that for each VM calls:

VBoxManage controlvm "machine_name" setlinkstate1 off   # unplug the cable from network card #1 
VBoxManage controlvm "machine_name" setlinkstate1 on    # plug the cable back 

Adjust the script if you use multiple network cards (setlinkstate - where N is the number of network card).

Iteration on active vms is based on https://superuser.com/a/1184354

@jportoles
Copy link

jportoles commented Apr 7, 2019

If the method above doesn't work, replace:

%VBoxManageEXE% controlvm %%p setlinkstate1 off
%VBoxManageEXE% controlvm %%p setlinkstate1 on

With:

%VBoxManageEXE% controlvm %%p nicpromisc1 deny
%VBoxManageEXE% controlvm %%p nicpromisc1 allow-all

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment