Skip to content

Instantly share code, notes, and snippets.

@seak0503
Last active August 29, 2015 14:10
Show Gist options
  • Save seak0503/9fed060cd977de8417fa to your computer and use it in GitHub Desktop.
Save seak0503/9fed060cd977de8417fa to your computer and use it in GitHub Desktop.
windows7上のvirtualboxの仮想サーバを制御するスクリプト
/*
windows7上のVirtualBoxの仮想サーバを起動するスクリプトです。
guest_os_name の部分を書き換えて使用してください。
*/
var WshShell = new ActiveXObject("WScript.Shell");
// Runの最後の引数にfalseを与えることで、waitせずにホストに制御を戻しています。
WshShell.Run("\"C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe\" startvm \"guest_os_name\"", 0, false);
WshShell = null;
/*
windows7上のVirtualBoxの仮想サーバを停止するスクリプトです。
guest_os_name の部分を書き換えて使用してください。
注意事項: ゲストのACPIによる自動シャットダウン可能にしておく必要があります。
*/
var WshShell = new ActiveXObject("WScript.Shell");
// Runの最後の引数をtrueにすることで、シャットダウン終了までスクリプト終了をwaitさせることができます。
WshShell.Run("\"C:\\Program Files\\Oracle\\VirtualBox\\VBoxManage.exe\" controlvm \"guest_os_name\" acpipowerbutton", 0, true);
WshShell = null;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment