Skip to content

Instantly share code, notes, and snippets.

@pol8139
Created March 4, 2019 16:15
Show Gist options
  • Select an option

  • Save pol8139/8ce920b46b5a1507d732efdac1f4ea48 to your computer and use it in GitHub Desktop.

Select an option

Save pol8139/8ce920b46b5a1507d732efdac1f4ea48 to your computer and use it in GitHub Desktop.
WindowsホストでVirtualBoxのゲストOSがネットワーク接続できなくなったときにネットワークアダプタの接続解除・再接続をする(とうちの環境ではうまくいく)。管理者権限で一定期間ごとに実行(VMも管理者権限で起動されてる必要あり)。
@echo off
ping -n 1 192.168.vm.ipaddress | find "TTL" > NUL
if not ERRORLEVEL 1 goto end
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "vmname" setlinkstate1 off
"C:\Program Files\Oracle\VirtualBox\VBoxManage.exe" controlvm "vmname" setlinkstate1 on
:end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment