回复 8# Batcher - @echo off
- set "retry_script_count=0"
- set "retry_count=0"
- set "process_count = 0"
- set "vmware_process_txt_count = 0"
- set "vmrun_count = 0"
-
- :command_loop
- vmrun stop "D:\VMware\VMLib\hengFengBankClone\hengFengBankOne.vmx" soft
-
- :check_process
- tasklist /FI "IMAGENAME eq vmware-vmx.exe" 2>NUL | find /I /N "vmware-vmx.exe">"F:\vmware_process.txt"
- if %~z1 EQU 0 (
- del "F:\vmware_process.txt"
- taskkill /f /t /im "vmware.exe"
- timeout /t 10
- shutdown /s /t 0
- )
- del "F:\vmware_process.txt"
- echo "虚拟机仍在运行中"
- IF %retry_script_count% EQU 3(
- exit /b 1
- )
- IF %retry_count% NEQ 5 (
- set /a retry_count+=1
- timeout /t 30
- del "F:\vmware_process.txt"
- goto:check_process
- )
- echo "连续检查5次,虚拟机仍没关闭,请等待程序再次尝试关闭虚拟机"
- timeout /t 30
- set /a retry_count=0
- set /a retry_script_count+=1
- setlocal
- set /a new_retry_script_count=%retry_script_count%+1
- echo "第%new_retry_script_count%次尝试关闭虚拟机"
- timeout /t 10
- endlocal
- goto:command_loop
复制代码 这是我修改之后的代码,问题详见上个楼层(13搂) |