2

我在Ubuntu 14.04上运行VirtualBox 5.0.16。我有32位版本的Windows7虚拟机。我想要做的是在客人上运行程序。首先,我尝试使用Python脚本用于此目的:在VirtualBox中的客户操作系统上运行程序

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

我尝试使用命令行后为了在客人上运行程序。所以,我正在运行的虚拟机,并试图执行以下命令:

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其中命令运行根本不存在。 如果有人知道任何可能的解决方案,这将是很好的。 谢谢。

回答

4

访问[开始菜单]和[搜索程序和文件]类型运行。 Inside [Run line]类型gpedit.msc。 在那里,进入Windows设置 - >安全设置 - >本地策略 - >安全选项 - > [帐户:限制本地帐户使用空白密码到控制台登录只有]并将其设置为已禁用。虚拟机重启后,应该解决。

+0

谢谢。我甚至没有想到这个方向。现在它工作得很好。 – aGGeRReS

+0

我没有在此刻我有这个问题:) – EugenG

0

到目前为止,我设法在VirtualBox中的客户操作系统上启动程序。 这个解决方案基于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 
...... 

启动细节:

蟒蛇2.7.6
pyvbox 1.0.0
主机OS - Ubuntu 14.04
Guest 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.

相关问题