Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to know if a user has administrative privileges from a VBScript

I need to check whether the user executing the script has administrative privileges on the machine.

I have specified the user executing the script because the script could have been executed with a user other than the logged on using something similar to "Runas".

@Javier: Both solutions work in a PC with an English version of Windows installed but not if the installed is in different language. This is because the Administrators group doesn't exist, the name is different for instance in Spanish. I need the solution to work in all configurations.

like image 544
Javier De Pedro Avatar asked Nov 19 '08 13:11

Javier De Pedro


People also ask

How do I ensure that my user has Administrator privilege?

Select Start, and select Control Panel. In the Control Panel window, select User Accounts and Family Safety > User Accounts > Manage User Accounts. In the User Accounts window, select Properties and the Group Membership tab. Make sure Administrator is selected.

How do I run a high privilege in VBScript?

To run a script 'As Admin' (with elevated permissions) using VBscript can be done by running ShellExecute and setting the runas flag. This can be used to run an executable, or to run an entire script (batch file or VBScript) with elevated permissions.


1 Answers

By doing this you break scenarios where the user has the required privs for your script but does not belong to Administrators. Instead of checking for group membership, check for the specific abilities you require.

like image 104
Jay Bazuzi Avatar answered Oct 18 '22 12:10

Jay Bazuzi