How to run application with elevated permissions in AutoLISP or ObjectARX

454 Views Asked by At

I need to run the application which requires elevated permissions in AutoCAD/ZWCAD.

By LISP I can run the application using:

(startapp "C:\\[path]\\Application.exe")

But for application requiring elevater permisions startapp returns nil and application not runs.

Tried also:

(setq Shell (vlax-get-or-create-object "Wscript.Shell"))
(setq updater(vlax-invoke-method Shell 'Exec (strcat path "Appname.exe" ) ) )
(vlax-release-object Shell)

but I got:

*error*: Automation error : WshShell.Exec : The requested operation requires elevation.

So is any other way to run external application requiring elevated permisions?

2

There are 2 best solutions below

0
CAD Developer On BEST ANSWER

I found that it can be done in both, LISP and C++ ObjectARX so:

LISP:

(startapp "C:\\[path]\\run.bat")

and in the run.bat

CALL "C:\[path]\Application.exe"

works OK on my site

ObjectARX C++

CString AppPath = _T("C:\\[path]\\");
CString App = AppPath + _T("Application.exe");
HINSTANCE aplication = ShellExecute(0, _T("open") , App , NULL , AppPath , SW_SHOWNORMAL);
1
Maxence On

May be you can try RunAs?

(startapp "runas /user:administrator C:\\[path]\\Application.exe")

Of course, you will be prompted for password.

You can find alternatives here: https://superuser.com/q/55809/60438