<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CLI | Easton Man's Blog</title>
	<atom:link href="https://blog.eastonman.com/blog/tag/cli/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.eastonman.com</link>
	<description>临渊羡鱼，不如退而结网</description>
	<lastBuildDate>Sun, 14 Feb 2021 10:49:42 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.5</generator>

<image>
	<url>https://blog.eastonman.com/wp-content/uploads/2021/02/cropped-Logo-e1613298891313-32x32.png</url>
	<title>CLI | Easton Man's Blog</title>
	<link>https://blog.eastonman.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Windows下VirtualBox CLI的使用分享</title>
		<link>https://blog.eastonman.com/blog/2021/02/windows-virtualbox-cli/</link>
					<comments>https://blog.eastonman.com/blog/2021/02/windows-virtualbox-cli/#comments</comments>
		
		<dc:creator><![CDATA[Easton Man]]></dc:creator>
		<pubDate>Wed, 10 Feb 2021 15:15:00 +0000</pubDate>
				<category><![CDATA[技术]]></category>
		<category><![CDATA[CLI]]></category>
		<category><![CDATA[VirtualBox]]></category>
		<guid isPermaLink="false">https://blog.eastonman.com/?p=331</guid>

					<description><![CDATA[<p>预计阅读时间： 2 分钟 由于开发环境的需要，我在日常使用的Windows笔记本上使用VirtualBox安装 [&#8230;]</p>
The post <a href="https://blog.eastonman.com/blog/2021/02/windows-virtualbox-cli/">Windows下VirtualBox CLI的使用分享</a> first appeared on <a href="https://blog.eastonman.com">Easton Man's Blog</a>.]]></description>
										<content:encoded><![CDATA[<p class="wpwc-reading-time">预计阅读时间： 2 分钟</p>
<amp-fit-text layout="fixed-height" min-font-size="6" max-font-size="72" height="80"><p>由于开发环境的需要，我在日常使用的Windows笔记本上使用VirtualBox安装了许多台Linux虚拟机（真的是许多台），由于VirtualBox本身没有开机自启，对其中的虚拟机更是没有开机自启的选项，因此需要使用的时候往往需要点击很多个按钮才能把全部需要使用的虚拟机打开。作为一个常年和CLI打交道并将自动化深刻融入生活的人，这显然难以接受。于是就萌生了使用脚本的想法。</p></amp-fit-text>



<p>当我上网一查，VirtualBox还真提供了相当完善的CLI支持，几乎所有的功能都可以在CLI里面完成，于是就写了几行脚本以帮助我一键开启所需的虚拟机甚至开机自动启动。</p>



<p>下面是一个例子，启动我的router虚拟机，这个虚拟机负责其它所有虚拟机流量的路由，将流量路由到宿主机上的代理软件。</p>



<pre class="wp-block-code"><code>cd C:\"Program Files"\Oracle\VirtualBox\
VBoxManage.exe startvm "Router" -type headless</code></pre>



<p>当然，VirtualBox CLI还支持相当多的命令，比如列出所有的虚拟机和UUID</p>



<pre class="wp-block-code"><code>C:\Program Files\Oracle\VirtualBox&gt; VBoxManage.exe list vms
"Ubuntu-Dev" {c8d949ad-f7ba-4b7b-b61e-127ff6f579b8}
"Router" {e6f7b3f8-cec0-48c3-a91c-ec2f565c7742}
"Debian-Dev" {562b4987-9f2b-4731-b86c-e225b08f87b0}
"Debian-Dev2" {e63f78b9-ac01-4d75-bff6-ff4b81083348}
"Security" {db6b8ec4-2578-4818-988e-b978d079ac48}</code></pre>



<p>全部的命令可以在<a href="https://www.virtualbox.org/manual/ch08.html" title="https://www.virtualbox.org/manual/ch08.html">VirtualBox Manual</a>里面找到。</p>



<h2 class="wp-block-heading">开机自启</h2>



<p>最简单的方式是把写好的bat脚本直接放进“启动”文件夹，但是这种方法会在开机时有CMD的窗口弹出，如果想要用一个看起来不那么像病毒的方式开机自启，可以使用vbs脚本无窗口运行bat，例如</p>



<pre class="wp-block-code"><code>Set ws = CreateObject("Wscript.Shell")
ws.run "cmd /c &lt;path to bat&gt;",0,true</code></pre>



<p>然后再将vbs脚本放进“启动”文件夹或者使用别的自启方式运行就可以了。</p>



<h2 class="wp-block-heading">参考</h2>



<p><a href="https://www.virtualbox.org/manual/ch08.html">https://www.virtualbox.org/manual/ch08.html</a></p>The post <a href="https://blog.eastonman.com/blog/2021/02/windows-virtualbox-cli/">Windows下VirtualBox CLI的使用分享</a> first appeared on <a href="https://blog.eastonman.com">Easton Man's Blog</a>.]]></content:encoded>
					
					<wfw:commentRss>https://blog.eastonman.com/blog/2021/02/windows-virtualbox-cli/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
			</item>
	</channel>
</rss>
