CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
CZ | EN | DE
Login or
registration
  Visitors: 2716

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

See also:
Tip 13408:How to increment the numbers in DWG texts by a specified value, e.g. +1, +10?
Tip 13402:Which products and features can I use for free with Flex Token licensing?
Tip 13316:Concerned about security of your Fusion designs? Where are hosted your USD Viewer files?
Tip 13263:Error when renaming assembly files in Design Assistant 2022.
Tip 13130:How to move a section to a different drawing sheet in Inventor?


Back   All CAD Tips



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:
Publish interactive 3D PDF models from AutoCAD, Inventor or Revit with Share3D More info


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