Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: How can I detect if a batch file is started as admin?  (Read 8452 times)

0 Members and 1 Guest are viewing this topic.

elel302

  • Guest
How can I detect if a batch file is started as admin?
« on: January 09, 2010, 12:48:49 PM »
How can I detect if a batch file is started as administrator?
 ???

Quantos



    Guru
  • Veni, Vidi, Vici
  • Thanked: 170
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Guru
  • OS: Linux variant
Re: How can I detect if a batch file is started as admin?
« Reply #1 on: January 09, 2010, 12:49:25 PM »
Can you give us some more information?
Evil is an exact science.

elel302

  • Guest
Re: How can I detect if a batch file is started as admin?
« Reply #2 on: January 09, 2010, 12:52:43 PM »
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.
 ???

Quantos



    Guru
  • Veni, Vidi, Vici
  • Thanked: 170
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Guru
  • OS: Linux variant
Re: How can I detect if a batch file is started as admin?
« Reply #3 on: January 09, 2010, 12:59:22 PM »
You could check your event log.
Evil is an exact science.

elel302

  • Guest
Re: How can I detect if a batch file is started as admin?
« Reply #4 on: January 09, 2010, 01:10:26 PM »
You could check your event log.

No I mean check admin from within the batch file.
 ???

Salmon Trout

  • Guest
Re: How can I detect if a batch file is started as admin?
« Reply #5 on: January 09, 2010, 02:36:56 PM »
..

Salmon Trout

  • Guest
Re: How can I detect if a batch file is started as admin?
« Reply #6 on: January 09, 2010, 02:38:02 PM »
Code: [Select]

if "%username%"=="Administrator" (
    echo User is Administrator
) else (
    echo User is not Administrator
)



Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: How can I detect if a batch file is started as admin?
« Reply #7 on: January 09, 2010, 04:08:27 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.

Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Salmon Trout

  • Guest
Re: How can I detect if a batch file is started as admin?
« Reply #8 on: January 09, 2010, 05:54:54 PM »
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.

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: How can I detect if a batch file is started as admin?
« Reply #9 on: January 09, 2010, 06:00:00 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.
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.

Quantos



    Guru
  • Veni, Vidi, Vici
  • Thanked: 170
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Guru
  • OS: Linux variant
Re: How can I detect if a batch file is started as admin?
« Reply #10 on: January 09, 2010, 06:03:51 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 :)
Evil is an exact science.

Helpmeh



    Guru

  • Roar.
  • Thanked: 123
    • Yes
    • Yes
  • Computer: Specs
  • Experience: Familiar
  • OS: Windows 8
Re: How can I detect if a batch file is started as admin?
« Reply #11 on: January 09, 2010, 06:09:55 PM »
I don't know if this is what you are looking for, Google works great though :)
Spot on quantos!
Where's MagicSpeed?
Quote from: 'matt'
He's playing a game called IRL. Great graphics, *censored* gameplay.