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

后端 未结 10 1981
不知归路
不知归路 2021-01-02 21:50

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

10条回答
  •  没有蜡笔的小新
    2021-01-02 22:26

    Function isAdmin
        Dim shell
        Set shell = CreateObject("WScript.Shell")
        isAdmin = false
        errorLevel = shell.Run("%comspec% /c net session >nul 2>&1", 0, True)
        if errorLevel = 0
            isAdmin = true
        End If
    End Function
    

提交回复
热议问题