Jump to content

Recommended Posts

Posted

Hi

Good morning everyone

I've searched the internet for information about this without success, so I thought I'd ask this here.

Is it possible to detect with Lisp if any Windows application running is doing so with administrator privileges?

Posted

I think you could do this by testing whether an operation that requires administrative rights can be performed.

For example, copying a file to the Windows\System folder.

Posted (edited)

like lido said In AutoLISP, cannot directly check for Windows Admin privileges, because AutoLISP is sandboxed within AutoCAD and cant see those types of windows things. tho I wouldn't try and copy files into sys folder. because if you do (admin rights) you would have a bunch of junk files in there. then the next step is to delete the copied file. that is a hop skip and a jump away from delete something needed.

 

I suggest using cmd prompt. it can list admin users and you can output that to a txt file that autocad can then read. if user name true.

 

something like "net localusers administrators > c:\admintest.txt"

Edited by mhupp
  • Like 1
Posted

what is your end goal with detecting privileges / admin access? There might be other ways to do what you want of course. 

Posted

Thanks for the answers.
I’ve done some research and found that all processes invoked from AutoCAD inherit the same privilege level. Therefore, it may be enough to know the privilege level with which AutoCAD is running (although ideally, it should work to check any process).
I need this to predict whether a task that requires privileges can be carried out or not

Posted
6 minutes ago, PGia said:

Thanks for the answers.
I’ve done some research and found that all processes invoked from AutoCAD inherit the same privilege level. Therefore, it may be enough to know the privilege level with which AutoCAD is running (although ideally, it should work to check any process).
I need this to predict whether a task that requires privileges can be carried out or not

Post your code.

 

Those that know how do this may feel that it's sus to 'check privileges to see if a task can be carried out', based on what little info you've posted, FWIW. 

Posted (edited)
7 hours ago, PGia said:

Thanks for the answers.
I’ve done some research and found that all processes invoked from AutoCAD inherit the same privilege level. Therefore, it may be enough to know the privilege level with which AutoCAD is running (although ideally, it should work to check any process).
I need this to predict whether a task that requires privileges can be carried out or not

 

Hi
Indeed, any process started from AutoCAD will inherit its privilege level.

For example, if AutoCAD opens an instance of Word, that instance will inherit the same privilege level as AutoCAD.
However, if a Word instance is already running and AutoCAD starts controlling it, its privilege level might be different. In that case, it might be necessary to check it in order to warn the user.
Could your issue be something similar to that?

As @mhupp says, there is no direct way to determine this from VLisp.
But there are some tricks to achieve it:
For example:

(defun acadAdmin? (/ arch r ruta ruta1 f sh)
  (if (findfile (setq ruta1 (strcat (getenv "TEMP") "\\acAdmin.si")))
    (vl-file-delete ruta1)
  )
  (if (setq arch (open (setq ruta (strcat (getenv "TEMP") "\\ea.bat")) "w"))
    (progn
      (write-line
	"@echo off
net session >nul 2>&1
if %errorlevel% == 0 (
  echo SI> \"%temp%\\acAdmin.si\"
)"
	arch
      )
      (close arch)
      (setq sh (vlax-create-object "WScript.Shell"))
      (vlax-invoke sh 'Run ruta 0 :vlax-true)
      (vlax-release-object sh)
      (vl-file-delete ruta)
      (if (setq r (findfile ruta1))
	(progn
	  (vl-file-delete ruta1)
	  T
	)
      )
    )
  )
)

 

This simply writes a .bat that when executed, creates the file "acAdmin.si" only if AutoCAD is running as admin

 

Edited by GLAVCVS

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...