how can a Perl script for Win32 tell if it's running as an admin?

Discussion in 'Perl Misc' started by Bennett Haselton, Jun 3, 2004.

  1. Is there a way for a Win32 Perl script running under Windows 2K/XP to
    determine if it's running as an administrator? (Not necessarily *the*
    administrator account, but any account with local admin privileges.)
    Other than a hack like trying to write to a normally restricted
    directory or registry key.

    -Bennett
    Bennett Haselton, Jun 3, 2004
    #1
    1. Advertising

  2. Bennett Haselton

    Jack Challen Guest

    Bennett Haselton wrote:
    > Is there a way for a Win32 Perl script running under Windows 2K/XP to
    > determine if it's running as an administrator? (Not necessarily *the*
    > administrator account, but any account with local admin privileges.)


    Try searching the docs for the Win32 module on CPAN for the string "admin"

    cheers

    jack
    Jack Challen, Jun 3, 2004
    #2
    1. Advertising

  3. Jack Challen <> wrote in message news:<tmCvc.1$OG.321@psinet-eu-nl>...
    > Bennett Haselton wrote:
    > > Is there a way for a Win32 Perl script running under Windows 2K/XP to
    > > determine if it's running as an administrator? (Not necessarily *the*
    > > administrator account, but any account with local admin privileges.)

    >
    > Try searching the docs for the Win32 module on CPAN for the string "admin"
    >
    > cheers
    >
    > jack


    Great minds think alike :) Before posting this mesasge I had already
    searched all the local HTML docs for the Win32 module for the string
    "admin", but I couldn't find anything, so that's when I asked here.

    I went to
    http://cpan.uwinnipeg.ca/dist/Win32/
    to do a search to see if anything had been created more recently, but
    the search bar wouldn't let me search just within that module.

    Are you aware of some function in that module that does what I need,
    and you were trying to lead me there without spoonfeeding me :) or
    were you just giving me a suggestion as the first place to look?
    Anybody have ideas for a second place?...

    -Bennett
    Bennett Haselton, Jun 3, 2004
    #3
  4. Bennett Haselton <> wrote:

    > Jack Challen <> wrote in message
    > news:<tmCvc.1$OG.321@psinet-eu-nl>...
    >> Bennett Haselton wrote:
    >> > Is there a way for a Win32 Perl script running under Windows
    >> > 2K/XP to determine if it's running as an administrator? (Not
    >> > necessarily *the* administrator account, but any account with
    >> > local admin privileges.)

    >>
    >> Try searching the docs for the Win32 module on CPAN for the
    >> string "admin"

    >
    > Great minds think alike :) Before posting this mesasge I had
    > already searched all the local HTML docs for the Win32 module for
    > the string "admin", but I couldn't find anything, so that's when I
    > asked here.


    Hmm. I searched my local copy of the Win32 docs and found
    Win32::IsAdminUser().

    I'm using Activestate Perl 5.8.3, build 809.


    C:\> perl -MWin32 -e "print $Win32::VERSION"
    0.22


    > Are you aware of some function in that module that does what I
    > need

    [snip rest of sentence]

    I suspect he was. :)
    David K. Wall, Jun 3, 2004
    #4
  5. MrReallyVeryNice, Jun 4, 2004
    #5
  6. Bennett Haselton

    Jack Challen Guest

    Bennett Haselton wrote:
    > I went to
    > http://cpan.uwinnipeg.ca/dist/Win32/
    > to do a search to see if anything had been created more recently, but
    > the search bar wouldn't let me search just within that module.


    Hmm... oddness
    I went to http://search.cpan.org/~nwclark/perl-5.8.4/win32/ext/Win32/Win32.pm

    and used my browser's "find in this page" option to look for "admin".
    This found me Win32::IsAdminUser()

    > Are you aware of some function in that module that does what I need,
    > and you were trying to lead me there without spoonfeeding me :) or
    > were you just giving me a suggestion as the first place to look?


    Sorry, had assumed zero effort on your part, and was trying to lead you to
    the answer, so your assumption was correct :)

    cheers
    jack
    Jack Challen, Jun 4, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. yogesh
    Replies:
    1
    Views:
    365
    Victor Bazarov
    Mar 14, 2007
  2. sarah Fernandes
    Replies:
    0
    Views:
    494
    sarah Fernandes
    Nov 1, 2010
  3. Phlip
    Replies:
    1
    Views:
    282
    Eero Saynatkari
    Sep 15, 2006
  4. Mike A
    Replies:
    17
    Views:
    259
    Dr John Stockton
    Nov 19, 2003
  5. Replies:
    4
    Views:
    293
    ccc31807
    Jul 29, 2011
Loading...

Share This Page