我唯一想到的是终止脚本,但如果终止错误的进程,这种方法是危险的,所以要小心。
- (defun LM:Terminate ( process / wmi server query name )
- (vl-catch-all-apply
- (function
- (lambda ( / name )
- (setq process (strcase process)
- wmi (vlax-create-object "WbemScripting.SWbemLocator")
- server (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil)
- query (vlax-invoke server 'execquery "Select * from Win32_Process")
- )
- (vlax-for item query
- (if
- (and
- (setq name (vlax-get item 'commandline))
- (vl-string-search process (strcase name))
- )
- (vlax-invoke item 'terminate)
- )
- )
- )
- )
- )
- (foreach object (list wmi server query)
- (if (and object (not (vlax-object-released-p object)))
- (vlax-release-object object)
- )
- )
- )
用进程名称调用以终止,例如:
- (LM:Terminate "Excel.exe")
|