关闭应用程序并让它触发批处理文件运行?

时间:2021-09-13 02:16:53

I'm trying to configure a virtual machine to start up from the machine being powered on. I have that working. Now I want to be able to shut down the entire machine once someone clicks Shutdown on the start menu of the virtual machine.

我正在尝试配置虚拟机以从启动的计算机启动。我有那个工作。现在,我希望能够在有人单击虚拟机的开始菜单上的“关闭”时关闭整个计算机。

I'm using VMware with Windows 7 images, if that helps.

我正在使用VMware和Windows 7映像,如果这有帮助的话。

Thank you!

1 个解决方案

#1


0  

invoke the start of the virtual machine with some kind of wait option and invoke shutdown afterwards.

使用某种等待选项调用虚拟机的启动,然后调用shutdown。

Something like this

像这样的东西

start /wait vmware-cmd cfg.vmx start 
shutdown -s

I don't have any vmware installed, I can't test it right now so I can't make sure the vmware-cmd doesn't return right away. If that is the case, then you must look for some loop mechanism in your bat file, something like

我没有安装任何vmware,我现在无法测试它,所以我无法确保vmware-cmd不会立即返回。如果是这种情况,那么你必须在bat文件中寻找一些循环机制,例如

vmware-cmd cfg.vmx start 
:again
vmware-cmd cfg.vmx getstate >state.txt
if (state.txt contains some string indicating still running) goto again
shutdown -s

#1


0  

invoke the start of the virtual machine with some kind of wait option and invoke shutdown afterwards.

使用某种等待选项调用虚拟机的启动,然后调用shutdown。

Something like this

像这样的东西

start /wait vmware-cmd cfg.vmx start 
shutdown -s

I don't have any vmware installed, I can't test it right now so I can't make sure the vmware-cmd doesn't return right away. If that is the case, then you must look for some loop mechanism in your bat file, something like

我没有安装任何vmware,我现在无法测试它,所以我无法确保vmware-cmd不会立即返回。如果是这种情况,那么你必须在bat文件中寻找一些循环机制,例如

vmware-cmd cfg.vmx start 
:again
vmware-cmd cfg.vmx getstate >state.txt
if (state.txt contains some string indicating still running) goto again
shutdown -s