1.

Solve : How can I detect if a batch file is started as admin??

Answer»

How can I detect if a batch file is started as administrator?
Can you give us some more information?You know in Vista or Windows 7 where you click Run as Administrator, well I wanna detect if the user has clicked that on the batch file.
You COULD check your event log.Quote from: Quantos on January 09, 2010, 12:59:22 PM

You could check your event log.

No I mean check admin from within the batch file.
..Code: [Select]
if "%username%"=="Administrator" (
echo User is Administrator
) else (
echo User is not Administrator
)


Quote from: SALMON Trout on January 09, 2010, 02:38:02 PM
Code: [Select]
if "%username%"=="Administrator" (
echo User is Administrator
) else (
echo User is not Administrator
)

That ony APPLIES to the Administrator account. I ASSUME the OP wants to make sure the user has RUN the batch as an administrator. Although I have 0 experence in this, I use XP.

Quote from: Helpmeh
That ony applies to the Administrator account. I assume the OP wants to make sure the user has RUN the batch as an administrator. Although I have 0 experence in this, I use XP.

In that case, Vista & 7 have the whoami command. Type whoami /? at the prompt for full information.
Quote from: Salmon Trout on January 09, 2010, 05:54:54 PM
In that case, Vista & 7 have the whoami command. Type whoami /? at the prompt for full information.

Well isn't that neat. Can you post it? I don't have vista or 7 so I can't SEE for myself. Quote from: Helpmeh on January 09, 2010, 06:00:00 PM
Well isn't that neat. Can you post it? I don't have vista or 7 so I can't see for myself.
I don't know if this is what you are looking for, Google works great though Quote from: Quantos on January 09, 2010, 06:03:51 PM
I don't know if this is what you are looking for, Google works great though
Spot on quantos!


Discussion

No Comment Found