I was writing some script which requires Run as administrator, if not , script should tell user to do so and exit.

But I didn't find how to get this test, whoami command returns same result whether you start cmd as or not with Run as admin

  • @John yes, command will say no enough permission and exit, but I want to give user active hint before that happen and gracefully exit my own script
    – intijk
    Nov 7, 2022 at 2:19
  • 1
  • 1
    @BlindSpots the logfile one is great, love that, than you!
    – intijk
    Nov 7, 2022 at 2:24
  • 1
    you can do command that requires admin > nul and then check %errorlevel% to see if the last command was succesful or not.
    – LPChip
    Nov 7, 2022 at 9:31


You must log in to answer this question.

Browse other questions tagged .