How to detect if CMD is running as Administrator/has elevated privileges?

后端 未结 13 1234
夕颜
夕颜 2020-12-04 07:51

From inside a batch file, I would like to test whether I\'m running with Administrator/elevated privileges.

The username doesn\'t change when \"Run as Administrator\

相关标签:
13条回答
  • Works for Win7 Enterprise and Win10 Enterprise

    @if DEFINED SESSIONNAME (
        @echo.
        @echo You must right click to "Run as administrator"
        @echo Try again
        @echo.
        @pause
        @goto :EOF
    )
    
    0 讨论(0)
提交回复
热议问题