运行 虚拟机 OS 上的程序在 VirtualBox 中
Run program on guest OS in VirtualBox
我 运行 在 Ubuntu 14.04 上安装 VirtualBox 5.0.16。我有 32 位版本 Windows7 的虚拟机。我想做的是 运行 来宾程序。为此,我首先尝试使用 Python 脚本:
vbox = virtualbox.VirtualBox()
session = virtualbox.Session()
vm = vbox.find_machine('Windows7')
vm.launch_vm_process(session, 'gui', '').wait_for_completion()
session = vm.create_session()
time.sleep(35)
gs = session.console.guest.create_session('win7', '')
process, stdout, stderr = gs.execute('C:\Windows\System32\cmd.exe', ['/C', 'tasklist'])
print stdout
机器启动良好,但我无法 运行 任何程序,因为出现以下错误:
Traceback (most recent call last): File "runonguest.py", line 39, in
gs = session.console.guest.create_session('win7', '') File "/usr/local/lib/python2.7/dist-packages/virtualbox/library_ext/guest.py",
line 24, in create_session
raise SystemError("GuestSession failed to start") SystemError: GuestSession failed to start
在我尝试使用命令行以便 运行 在来宾上编程之后。所以我有 运行ning 虚拟机,并尝试执行以下命令:
VBoxManage guestcontrol "Windows7" --username win7 run --exe C:\Windows\System32\cmd.exe --wait-stdout -- "C:\Windows\System32\cmd.exe" "/C" "tasklist"
但它给我带来了下一个错误:
VBoxManage: error: VERR_ACCOUNT_RESTRICTED VBoxManage: error: Details:
code VBOX_E_IPRT_ERROR (0x80bb0005), component GuestSessionWrap,
interface IGuestSession, callee nsISupports VBoxManage: error:
Context: "WaitForArray(ComSafeArrayAsInParam(aSessionWaitFlags), 30 *
1000, &enmWaitResult)" at line 938 of file VBoxManageGuestCtrl.cpp
我一直在寻找可能的解决方案,但大多数都是针对旧版本的 VirtualBox,其中命令 运行 根本不存在。
如果有人知道任何可能的解决方案,那就太好了。
谢谢。
到目前为止,我设法在 VirtualBox 中的客户机 OS 上启动了程序。
该解决方案基于(如我所见,未记录)事实,即 VBox API 在用户帐户没有密码的情况下不会启动会话。所以我在来宾的 Windows7.
上创建了新的用户帐户和密码
对于Python只需写:
In [15]: gs = session.console.guest.create_session('user', 'user')
In [16]: process, stdout, stderr = gs.execute('C:\Windows\System32\cmd.exe', ['/C', 'tasklist'])
In [17]: print stdout
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 12 K
System 4 Services 0 528 K
smss.exe 264 Services 0 688 K
csrss.exe 340 Services 0 2,824 K
wininit.exe 388 Services 0 3,128 K
csrss.exe 400 1 3,572 K
winlogon.exe 440 1 5,556 K
.....
对于控制台使用只需写:
VBoxManage guestcontrol "Windows7" --verbose --username user --password user run --exe "C:\
Windows\System32\cmd.exe" -- cmd.exe /c tasklist
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 12 K
System 4 Services 0 532 K
smss.exe 264 Services 0 688 K
csrss.exe 340 Services 0 2,848 K
wininit.exe 388 Services 0 3,128 K
csrss.exe 400 1 3,572 K
winlogon.exe 440 1 5,556 K
......
发布详情:
python 2.7.6
pyvbox 1.0.0
主持人 OS - Ubuntu 14.04
访客 OS - Windows7 x32
VirtualBox 5.0.16
UPD: 根据 iugene 的 回答,真正的解决方案是 Windows 安全策略。
Access [Start menu] and in [search program and files] type Run. Inside
[Run line] type gpedit.msc. There, go to Windows Settings -> Security
Settings -> Local Policies -> Security Options -> [Accounts: Limit
local account use of blank passwords to console logon only] and set it
to Disabled. After a VM restart, should be solved.
访问[开始菜单]并在[搜索程序和文件]中键入运行。
在 [运行 行] 中键入 gpedit.msc。
在那里,转到 Windows 设置 -> 安全设置 -> 本地策略 -> 安全选项 -> [ 帐户:将使用空白密码的本地帐户限制为仅控制台登录] 和将其设置为 已禁用 。 VM重启后,应该可以解决。
我 运行 在 Ubuntu 14.04 上安装 VirtualBox 5.0.16。我有 32 位版本 Windows7 的虚拟机。我想做的是 运行 来宾程序。为此,我首先尝试使用 Python 脚本:
vbox = virtualbox.VirtualBox()
session = virtualbox.Session()
vm = vbox.find_machine('Windows7')
vm.launch_vm_process(session, 'gui', '').wait_for_completion()
session = vm.create_session()
time.sleep(35)
gs = session.console.guest.create_session('win7', '')
process, stdout, stderr = gs.execute('C:\Windows\System32\cmd.exe', ['/C', 'tasklist'])
print stdout
机器启动良好,但我无法 运行 任何程序,因为出现以下错误:
Traceback (most recent call last): File "runonguest.py", line 39, in gs = session.console.guest.create_session('win7', '') File "/usr/local/lib/python2.7/dist-packages/virtualbox/library_ext/guest.py", line 24, in create_session raise SystemError("GuestSession failed to start") SystemError: GuestSession failed to start
在我尝试使用命令行以便 运行 在来宾上编程之后。所以我有 运行ning 虚拟机,并尝试执行以下命令:
VBoxManage guestcontrol "Windows7" --username win7 run --exe C:\Windows\System32\cmd.exe --wait-stdout -- "C:\Windows\System32\cmd.exe" "/C" "tasklist"
但它给我带来了下一个错误:
VBoxManage: error: VERR_ACCOUNT_RESTRICTED VBoxManage: error: Details: code VBOX_E_IPRT_ERROR (0x80bb0005), component GuestSessionWrap, interface IGuestSession, callee nsISupports VBoxManage: error: Context: "WaitForArray(ComSafeArrayAsInParam(aSessionWaitFlags), 30 * 1000, &enmWaitResult)" at line 938 of file VBoxManageGuestCtrl.cpp
我一直在寻找可能的解决方案,但大多数都是针对旧版本的 VirtualBox,其中命令 运行 根本不存在。 如果有人知道任何可能的解决方案,那就太好了。 谢谢。
到目前为止,我设法在 VirtualBox 中的客户机 OS 上启动了程序。 该解决方案基于(如我所见,未记录)事实,即 VBox API 在用户帐户没有密码的情况下不会启动会话。所以我在来宾的 Windows7.
上创建了新的用户帐户和密码对于Python只需写:
In [15]: gs = session.console.guest.create_session('user', 'user')
In [16]: process, stdout, stderr = gs.execute('C:\Windows\System32\cmd.exe', ['/C', 'tasklist'])
In [17]: print stdout
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 12 K
System 4 Services 0 528 K
smss.exe 264 Services 0 688 K
csrss.exe 340 Services 0 2,824 K
wininit.exe 388 Services 0 3,128 K
csrss.exe 400 1 3,572 K
winlogon.exe 440 1 5,556 K
.....
对于控制台使用只需写:
VBoxManage guestcontrol "Windows7" --verbose --username user --password user run --exe "C:\
Windows\System32\cmd.exe" -- cmd.exe /c tasklist
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
System Idle Process 0 Services 0 12 K
System 4 Services 0 532 K
smss.exe 264 Services 0 688 K
csrss.exe 340 Services 0 2,848 K
wininit.exe 388 Services 0 3,128 K
csrss.exe 400 1 3,572 K
winlogon.exe 440 1 5,556 K
......
发布详情:
python 2.7.6
pyvbox 1.0.0
主持人 OS - Ubuntu 14.04
访客 OS - Windows7 x32
VirtualBox 5.0.16
UPD: 根据 iugene 的 回答,真正的解决方案是 Windows 安全策略。
Access [Start menu] and in [search program and files] type Run. Inside [Run line] type gpedit.msc. There, go to Windows Settings -> Security Settings -> Local Policies -> Security Options -> [Accounts: Limit local account use of blank passwords to console logon only] and set it to Disabled. After a VM restart, should be solved.
访问[开始菜单]并在[搜索程序和文件]中键入运行。 在 [运行 行] 中键入 gpedit.msc。 在那里,转到 Windows 设置 -> 安全设置 -> 本地策略 -> 安全选项 -> [ 帐户:将使用空白密码的本地帐户限制为仅控制台登录] 和将其设置为 已禁用 。 VM重启后,应该可以解决。