CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 2346 

CAD tip CAD tip # 12306:

Question CAD 
 %  platform  category 
Q - question

How to check if a specific application or process is running?

A - answer If you need to check in your LISP application whether a specific Windows application or process (items you can see in the Task Manager) is running, you can use the following LISP function:

(defun isRunning? (procname / apps item lst meth1 meth2 WMI)
  (setq WMI (vlax-create-object "WbemScripting.SWbemLocator")
        meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil)
        meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process"))
  (vlax-for item meth2
    (setq lst (append lst (list (vlax-get item 'CommandLine))))
  )
  (vlax-release-object WMI)
  (vlax-release-object meth1)
  (vlax-release-object meth2)
  (setq lst (vl-remove nil lst))

  (vl-some '(lambda (s) (wcmatch (strcase s) (strcat "*" (strcase procname) "*"))) lst)
)

For the procname parameter, use any substring identifying the runstring of the specific application or process - e.g. the parameter "acad.exe" should always return T, as AutoCAD is running for sure:

(isRunning? "acad.exe")

Is the Windows indexing process running?

(isRunning? "SearchProtocolHost")

ACAD
100% Win  CAD 
8.7.2019    177×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 12303:3D model reconstructed from a series of photos has holes in it. How to fix it?
Tip 12279:PropByLayer - an inverse function to SetByLayer.
Tip 12255:How to change the number of CPUs used in Nastran for analyses?
Tip 12215:How to change truecolor DWG objects to indexed ACI colors?
Tip 12127:AutoCAD slower after obeying the recommendation from DELL Precision Optimizer.


Back   All CAD Tips All CAD tips&tricks



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Generate hatch patterns automatically from your DWG drawings with
HGEN 2006 More info


Please use these tips at your own risk.
CAD Studio (Xanadu) is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist