Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Windows 綜合教學 >> 關於 Windows

Win7 VirtualBox 虛擬機開機自動後台啟動:Headless 模式 + 啟動資料夾腳本

編輯:關於 Windows

每次手動開啟 VirtualBox 再啟動 Linux 虛擬機再用 SSH 連線很繁瑣?本文教你用 VBoxManage startvm --type headless 實現無視窗後台啟動,並放入啟動資料夾達成開機自動執行,讓 Linux 服務隨 Windows 開機即可用。

核心指令

VBoxManage startvm "VM名稱或UUID" --type headless
  • --type headless:無 GUI 視窗,純後台運行。
  • 指令需在 VirtualBox 安裝目錄下執行(含 VBoxManage.exe)。

完整設定步驟

  1. 確認 VirtualBox 安裝路徑(例:D:\VirtualBox)與虛擬機名稱(例:study)。
  2. 用記事本建立 virtualbox_start.bat,內容:
    D:\VirtualBox\VBoxManage startvm study --type headless
  3. 將 .bat 檔放入 C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup(所有使用者啟動資料夾)。
  4. 重開機驗證:工作管理員 → 服務/詳細資料可見 VBoxHeadless.exe 進程,SSH 連線測試正常。

進階管理指令

VBoxManage controlvm study pauseVBoxManage controlvm study resumeVBoxManage controlvm study resetVBoxManage controlvm study poweroffVBoxManage controlvm study savestate
操作指令範例
暫停
恢復
重置
強制關機
儲存狀態關機

注意事項

  • 虛擬機需設為「橋接網路」或「NAT + 埠轉向」才能從宿主機/區網 SSH 連入。
  • 若需圖形介面,移除 --type headless 即可。
  • 關機時 Windows 會嘗試正常關閉進程,建議在虛擬機內設定 systemd 服務或 acpid 捕捉電源事件優雅關機。
Copyright © Windows教程網 All Rights Reserved