Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 68383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:24:28+00:00 2026-05-10T19:24:28+00:00

How can my vbscript detect whether or not it is running in a UAC

  • 0

How can my vbscript detect whether or not it is running in a UAC elevated context?

I have no problem detecting the user, and seeing if the user is within the Administrators group. But this still doesn’t answer the question of whether the process has elevated privs or not, when running under Vista or Windows 2008. Please note, I need only to detect this status; not attempt to elevate or (err ..) de-elevate.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:24:29+00:00Added an answer on May 10, 2026 at 7:24 pm

    The method I finally settled on depends on the fact that Vista and Windows 2008 have the whoami.exe utility, and it detects the integrity level of the user who owns the process. A couple of screenshots help here:

    WHOAMI, normal and elevated, on Vista http://lh3.ggpht.com/_Svunm47buj0/SQ6ql4iNjPI/AAAAAAAAAeA/iwbcSrAZqRg/whoami%20-%20adminuser%20-%20groups%20-%20cropped.png?imgmax=512

    You can see that when cmd is running elevated, whoami /groups reports a ‘High’ mandatory integrity level and a different SID than when running non-elevated. In the pic, the top session is normal, the one underneath is running elevated after UAC prompt.

    Knowing that, here is the code I used. It essentially checks the OS version, and if it is Vista or Server 2008, calls CheckforElevation which runs whoami.exe /groups, and looks for the string S-1-16-12288 in the output. In this example I just echo status; in the real script I branch to different actions based on the result.

    sub GetOSVersion Dim strComputer, oWMIService, colOSInfo, oOSProperty, strCaption, strOSFamily strComputer = '.' Set oWMIService = GetObject('winmgmts:\\' & strComputer & '\root\cimv2') Set colOSInfo = oWMIService.ExecQuery('Select * from Win32_OperatingSystem') 'I hate looping through just to get one property. But dunno another way! For Each oOSProperty in colOSInfo    strCaption = oOSProperty.Caption  Next If InStr(1,strCaption, 'Vista', vbTextCompare) Then strOSFamily = 'Vista' If InStr(1,strCaption, '2008', vbTextCompare) Then strOSFamily = '2008' If InStr(1,strCaption, 'XP', vbTextCompare) Then strOSFamily = 'XP' If InStr(1,strCaption, '2003', vbTextCompare) Then strOSFamily = '2003' If InStr(1,strCaption, '2000', vbTextCompare) Then strOSFamily = '2000' If strOSFamily = '' Then      Wscript.Echo 'No known OS found. (Script can detect Windows 2000, 2003, XP, Vista, 2008.)'  Else      Wscript.Echo 'OS Family = ' & strOSFamily End If Select Case strOSFamily 'if Vista/2008 then call CheckforElevation Case 'Vista'     CheckforElevation Case '2008'     CheckforElevation Case Else     Exit Sub End Select end sub  sub CheckforElevation 'test whether user has elevated token  Dim oShell, oExecWhoami, oWhoamiOutput, strWhoamiOutput, boolHasElevatedToken Set oShell = CreateObject('WScript.Shell') Set oExecWhoami = oShell.Exec('whoami /groups') Set oWhoamiOutput = oExecWhoami.StdOut strWhoamiOutput = oWhoamiOutput.ReadAll If InStr(1, strWhoamiOutput, 'S-1-16-12288', vbTextCompare) Then boolHasElevatedToken = True If boolHasElevatedToken Then     Wscript.Echo 'Current script is running with elevated privs.' Else     Wscript.Echo 'Current script is NOT running with elevated privs.' End If end sub 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 100k
  • Answers 100k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Have a look at this Basically it looks as if… May 11, 2026 at 7:54 pm
  • Editorial Team
    Editorial Team added an answer As @mark clarified it's a Linux system, the script could… May 11, 2026 at 7:54 pm
  • Editorial Team
    Editorial Team added an answer I do not know of any software to do this.… May 11, 2026 at 7:54 pm

Related Questions

I get to dust off my VBScript hat and write some classic ASP to
My programming environment includes scripts for setting up my autobuild on a clean machine.
I'm using old VBScript in my ASP application. Trying to search and replace string
I need to call a VBScript file (.vbs file extension) in my C# Windows

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.