Pages

Showing posts with label Check Admin Rights. Show all posts
Showing posts with label Check Admin Rights. Show all posts

Thursday, 21 June 2012

Check Admin Rights


Check if the current user is a local administrator using the Windows Installer service.


Dim oInst, oSess, iAdmin, oProducts
Const msiUILEVELNONE = 2
Set oInst = CreateObject("WindowsInstaller.Installer")
oInst.UILevel = msiUILEVELNONE
Set oProducts = oInst.Products
Set oSess = oInst.OpenProduct(oProducts(0))
iAdmin = oSess.Property("AdminUser")
If iAdmin = 1 Then
Msgbox "You are a local administrator!", vbInformation, "ADMINISTRATOR"
Else
Msgbox "You are not a local administrator!", vbCritical, "NON-ADMIN"
End If