two more ways - fast and backward compatible .
fltmc >nul 2>&1 && (
echo has admin permissions
) || (
echo has NOT admin permissions
)
fltmc
command is available on every windows system since XP so this should be pretty portable.
One more really fast solution tested on XP
,8.1
,7
- there's one specific variable =::
which is presented only if the console session has no admin privileges.As it is not so easy to create variable that contains =
in it's name this is comparatively reliable way to check for admin permission (it does not call external executables so it performs well)
setlocal enableDelayedExpansion
set "dv==::"
if defined !dv! (
echo has NOT admin permissions
) else (
echo has admin permissions
)
If you want use this directly through command line ,but not from a batch file you can use:
set ^"|find "::"||echo has admin permissions