Run As Admin Check

ForeverZer0 Sep 3rd, 2012 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def elevated?
  2.   whoami = `whoami /groups` rescue nil
  3.   if whoami =~ /S-1-16-12288/
  4.     true
  5.   else
  6.     admin = `net localgroup administrators | find "%USERNAME%"` rescue ""
  7.     admin.empty? ? false : true
  8.   end
  9. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand