Skip to content

Instantly share code, notes, and snippets.

@ecormaksin
Created January 12, 2020 09:54
Show Gist options
  • Save ecormaksin/b03aa3f41fe6392b95df4077cca758b9 to your computer and use it in GitHub Desktop.
Save ecormaksin/b03aa3f41fe6392b95df4077cca758b9 to your computer and use it in GitHub Desktop.
VirtualBoxの仮想マシンを作成するWindowsバッチ
@echo off
setlocal enabledelayedexpansion
setlocal
set CURRENT_FOLDER=%~dp0
cd %CURRENT_FOLDER%
set VM_NAME=CentOS7-01
set MEDIUM_FILE_PATH=%HOME%\Downloads\CentOS-7-x86_64-Minimal-1908.iso
set VM_FILE_PATH=%HOME%\VirtualBox VMs\%VM_NAME%\%VM_NAME%.vdi
rem ===============================================================
VBoxManage createvm --name "%VM_NAME%" --register
VBoxManage modifyvm "%VM_NAME%" --ostype Linux26_64 --memory 8192 --vram 128 --cpus 2 --boot1 dvd --boot2 disk --boot3 none --boot4 none --nic1 nat --nictype1 82540EM --cableconnected1 on --natpf1 SSH,tcp,,50022,,22 --nic2 hostonly --hostonlyadapter2 "VirtualBox Host-Only Ethernet Adapter" --nictype2 82540EM --cableconnected2 on
VBoxManage storagectl "%VM_NAME%" --name IDE --add ide --controller PIIX4 --portcount 2 --hostiocache on --bootable on
VBoxManage storageattach "%VM_NAME%" --storagectl IDE --port 0 --device 0 --type dvddrive --medium "%MEDIUM_FILE_PATH%"
VBoxManage createmedium disk --filename "%VM_FILE_PATH%" --size 262144 --variant Standard
VBoxManage storagectl "%VM_NAME%" --name SATA --add sata --controller IntelAhci --portcount 1 --hostiocache off --bootable on
VBoxManage storageattach "%VM_NAME%" --storagectl SATA --port 0 --device 0 --type hdd --medium "%VM_FILE_PATH%"
endlocal
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment