seven.reeds has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Windows has script hooks for user login/logout and system start/stop these are available through the gpedit tool. I have a perl script that I would like to run via these hooks. My windows admin is telling me some troubling things though.

My goals include:

On a Linux box I might put the script in /usr/local/sbin and let a sudo'ers file deal with the execution. Is there a Windows equiv to sudo?

My Windows admin is telling me that Windows will not let him run perl scripts as Administrator -- a la, right click the script name and select "Run as Administrator". He says the only way for this script to work is to have it in a place where ALL users can "see" it and execute it.

Since the script uses paths and passwords for things that regular users should not know I am very concerned.

Is there a way to protect the script while allowing it to be run by the masses?

Seven

Replies are listed 'Best First'.
Re: perl based windows "login" script
by tobyink (Canon) on Dec 19, 2012 at 20:43 UTC

    runas is roughly equivalent to sudo.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
Re: perl based windows "login" script
by VinsWorldcom (Prior) on Dec 19, 2012 at 21:02 UTC

    As tobyink points out, 'runas' is the Windows command line equivalent to 'sudo', so have a look at that.

    Also, I'm on Windows 7 x64 with Strawberry Perl 5.16.1. When I Shift-right-click on a .pl file, I can confirm I do NOT get a "Run as administrator" option. However, I DO get that option for .bat (Windows batch files). Strawberry Perl comes with 'pl2bat', so maybe give that a test drive.

    NOTE: 'pl2bat' basically wraps the Perl script in a Windows batch file - it doesn't "convert" it.

Re: perl based windows "login" script
by rpnoble419 (Pilgrim) on Dec 19, 2012 at 23:37 UTC