1.

Solve : Simple .exe to detect if that .exe is being run as admin or user?

Answer»

os: xp and 7
I need a simple .exe or .bat file, for xp and 7 to detect if that .exe is being run with administrator rights or user rights.
google doesn't help MUCH, and any help WOULD be appreciated.Batch to TRY if English is system language:

for /f "tokens=4" %%A in ('net user %username% ^| find "LOCAL Group Memberships"') do set usertype=%%A


Thank you very much, that was exactly what i was looking for
Code: [Select]for /f "tokens=4" %%A in ('net user %username% ^| find "Local Group Memberships"') do set usertype=%%A
@echo off
pause
Quote from: fhunt on April 28, 2012, 02:05:00 AM

google doesn't help much

Really?

Quote from: fhunt on April 28, 2012, 02:56:58 AM
Thank you very much, that was exactly what i was looking for
Code: [Select]for /f "tokens=4" %%A in ('net user %username% ^| find "Local Group Memberships"') do set usertype=%%A
@echo off
pause

Personally I would do something like this... I would put @echo off as the very first line of the batch SCRIPT (this is usual)

@echo off
for /f "tokens=4" %%A in ('net user %username% ^| find "Local Group Memberships"') do set usertype=%%A
if "%usertype%"=="*Administrators" goto Admin
echo This user is not a member of the Administrators group
goto End
:Admin
echo This user is a member of the Administrators group
:End
pause


Discussion

No Comment Found