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

  • Thread starter Bennett Haselton
  • Start date
B

Bennett Haselton

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
 
J

Jack Challen

Bennett said:
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
 
B

Bennett Haselton

Jack Challen said:
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
 
D

David K. Wall

Bennett Haselton said:
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. :)
 
J

Jack Challen

Bennett said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top