DevOps: Difference between revisions

From Han Wiki
Jump to navigation Jump to search
add category
add virtualbox section
Line 4: Line 4:


[[Category:Development]]
[[Category:Development]]
== VirtualBox ==
=== Running a VM headless (in the background, like a service) or without GUI ===
''Last tested on Windows 10 Home x64 (v1511, build 10586.318) + VirtualBox v5.0.20 r106931''
<span class="shell">Givens:</span>
* the name of the virtual machine is '''virtualmachine'''
We first create a batch file that runs the VM.  Create a file named <span class="package">vm-run.bat</span> with the following content.
<source lang="dosbatch">
cd "c:\Program Files\Oracle\VirtualBox\"
VBoxHeadless -s virtualmachine -v on
</source>
We can just use the batch file above, however, it opens up the shell to run the batch file. We use Windows-based script host using VBS to run the file.  Create a file named <span class="package">vm-run.vbs</span> with the following content.
<source lang="vbnet">
set WshShell = WScript.CreateObject("WScript.Shell")
obj = WshShell.Run("vm-run.bat",0)
set WshShell = Nothing
</source>
Use the following line to run the VM in the background: <code>wscript vm-run.vbs</code>
</source>
<span class="shell">optional:</span>
You can optionally create a shortcut on your Desktop with the following value in Target:
<source lang="dosbatch">
C:\Windows\System32\wscript.exe C:\Files\tools\vm.run.vbs
</source>
To check if it's running, go to Task Manager (taskmgr using CLI) and check Details tab. There should be 3 instances of VBoxHeadless.exe  processes running.

Revision as of 09:10, 12 May 2016

Development environment

Docker notes

VirtualBox

Running a VM headless (in the background, like a service) or without GUI

Last tested on Windows 10 Home x64 (v1511, build 10586.318) + VirtualBox v5.0.20 r106931

Givens:

  • the name of the virtual machine is virtualmachine

We first create a batch file that runs the VM. Create a file named vm-run.bat with the following content.

cd "c:\Program Files\Oracle\VirtualBox\"
VBoxHeadless -s virtualmachine -v on

We can just use the batch file above, however, it opens up the shell to run the batch file. We use Windows-based script host using VBS to run the file. Create a file named vm-run.vbs with the following content.

set WshShell = WScript.CreateObject("WScript.Shell")
obj = WshShell.Run("vm-run.bat",0)
set WshShell = Nothing

Use the following line to run the VM in the background: wscript vm-run.vbs </source>

optional:

You can optionally create a shortcut on your Desktop with the following value in Target:

C:\Windows\System32\wscript.exe C:\Files\tools\vm.run.vbs

To check if it's running, go to Task Manager (taskmgr using CLI) and check Details tab. There should be 3 instances of VBoxHeadless.exe processes running.