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

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    476×  
Prices - CAD eShop:
applies to: AutoCAD ·

See also:
Tip 12392:Export unfolds of sheetmetal parts to DXF - parameters for iLogic and VBA
Tip 12341:Check collisions of the machined model with the CNC machine.
Tip 12325:How to display a DWG from Advance Steel including AS objects? (AST viewer)
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.


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:
Increase your productivity with our set of BIM add-on functions for Autodesk Revit
CADstudio Revit Tools More info


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