CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz] ARKANCE | CONTACT - CZ | SK | EN | DE
Over 1.095.000 registered users (EN+CZ). AutoCAD tips, Inventor tips, Revit tips. Try the new precise Engineering calculator. New AutoCAD 2026 commands and variables.

CAD tip CAD tip # 12306:

Question

CAD 
 %  platform  category 
A
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% WinCAD
8.7.2019    10578×   Expert
Share the tip:
Digg it! Del.icio.us Facebook Twitter Google bookmark Technorati StumbleUpon
applies to: AutoCAD ·

See also:
Tip 14613:How to set the elevation of objects according to the value of Object Data, OD? (OD2Z)
Tip 14604:QRcode - dynamically generated QR codes in AutoCAD.
Tip 14593:Revit is slow on a new workstation on structural and steel connections projects.
Tip 14549:How to reduce PDF document size in Bluebeam Revu?
Tip 14500:Autodesk starts using OTP (One-Time Passcode) verification on user accounts.


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
  



Featuring:
Export 3D VRML scenes from AutoCAD and Inventor
VRMLout More info


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