AutoLisp function to Obtain app path

AutoLisp function to Obtain app path

HE-MJJ
Advocate Advocate
250 Views
1 Reply
Message 1 of 2

AutoLisp function to Obtain app path

HE-MJJ
Advocate
Advocate

How can I obtain the current path of an application like for example AcroRD32.exe of FoxitPDFReader.exe using autolisp? I want to (startapp the application making sure it works on any computer with the app possibly installed on different locations.

0 Likes
251 Views
1 Reply
Reply (1)
Message 2 of 2

Sea-Haven
Mentor
Mentor

Using powershell you can find a file you can run a bat file that exports to a file can be found via lisp.

 

So the how to, this exports the file path to the file d:\acadtemp\ans.txt so can read that via a lisp. You need to save the bat and ps1 file and set the path correct in code.

 

 

(defun run_and_wait (strCommand / WScript_obj)
  (vl-load-com)
  (if (setq WScript_obj (vlax-get-or-create-object "WScript.Shell"))
    (vl-catch-all-apply 'vlax-invoke-method (list WScript_obj "Run" strCommand 4 :vlax-true))
  );if
);defun
(run_and_wait "d:\\acadtemp\\testgetfile.bat")

 

 

testgetfile.bat

 

 

powershell.exe -ExecutionPolicy Bypass -Command D:\acadtemp\testgetfile.ps1

 

 

ps1 file

 

 

$filename = 'Bricscad.exe'
$searchinfolder = 'c:\program files\Bricsys*'
Get-ChildItem -Path $searchinfolder -Filter $filename -Recurse | %{$_.FullName} >d:\acadtemp\ans.txt

 

 

 

 

0 Likes