How to use API to check Inventor instance "run as administrator"?

How to use API to check Inventor instance "run as administrator"?

liminma8458
Collaborator Collaborator
521 Views
2 Replies
Message 1 of 3

How to use API to check Inventor instance "run as administrator"?

liminma8458
Collaborator
Collaborator

Hi,

 

I understand Inventor has to be "Run as administrator" to make all the Addins work well. But sometimes the user indeed open Inventor without administrator right.

 

So how to use code (in VB.NET) to detect whether the current Inventor is "run as administrator" or not?

 

 

 

 

 

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes
Accepted solutions (1)
522 Views
2 Replies
Replies (2)
Message 2 of 3

Curtis_Waguespack
Consultant
Consultant
Accepted solution

Hi @liminma8458 

 

 

Imports System.Security.Principal

Dim identity = WindowsIdentity.GetCurrent()
Dim principal = new WindowsPrincipal(identity)
Dim isElevated as Boolean = principal.IsInRole(WindowsBuiltInRole.Administrator) 
If isElevated Then
  MessageBox.Show("Is Admin")
Else
  MessageBox.Show("Is NOT Admin")
End If

 

See this link:

admin - How to check if application is running as administrator VB.NET - Stack Overflow

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

EESignature

0 Likes
Message 3 of 3

liminma8458
Collaborator
Collaborator

Curtis,

Thank you so much. I wonder why I missed the Stack Overflow.

^_^

Thanks
Limin
Inventor pro 2023 64 bit update 5.3; Windows 11 pro 64 bit version 24H2; Office 2013 64 bit

Download iCable in App Store to Create Cables Easily

0 Likes