http://www.perlmonks.org?node_id=108329


in reply to cgi wrapper??

Since I brought up the scheduler in the previous thread, I'll defend my choice ;-)

Scheduler is built into NT/W2K/XP/2002/yadayadayada). So no need to install it.

Win32::AdminMisc::ScheduleAdd( $Machine, $Time, $DOM, $DOW, $Flags, $Command )
will schedule $Command to run on the computer $Machine at $Time on the day of the month determined by the bitmask $DOM and the day of the week determined by the bitmask DOW.

So, you loop through your list of servers, executing the function with each iteration. What's so tedious about that?

Replies are listed 'Best First'.
Re: Re: cgi wrapper??
by OzzyOsbourne (Chaplain) on Aug 28, 2001 at 16:10 UTC
    Note: To add things to the AT scheduler on a windows machine, you don't actually need a module. You can do this via command line from a remote PC using at \\computername. See AT /? for further info.

    -OzzyOsbourne

      Right, but at is very cumbersome and it's much more easier to use Win32::AdminMisc for this - i.e. if you want to add a scheduled task but don't want to add it if it's already there, then you have to parse the output of "at" - This could be tricky and requires an extra system call for each addition. It's much easier to use the ScheduleList() method and then use ScheduleAdd() if you need to.

      If it's well written and easy to use, I prefer to use a module than a system call.

      Error: Keyboard not attached. Press F1 to continue.
Re: Re: cgi wrapper??
by $code or die (Deacon) on Aug 28, 2001 at 15:55 UTC
    Excellent, I forgot that you can specify a remote machine for ScheduleAdd(). That would be the best way to do it, unless it's something that has to be executed on demand.

    Error: Keyboard not attached. Press F1 to continue.
Re: Re: cgi wrapper??
by RayRay459 (Pilgrim) on Aug 28, 2001 at 20:26 UTC
    Do the targer machines have to have AdminMisc module installed or just the machine running the script?
    Thanks,
    Ray
      Just the machine running the script needs to have AdminMisc installed. The target machines need to have the scheduler/mstask service running.
        A couple of other things worth thinking about with Scheduler is permissions:

        1. It could get tricky if the target machines are on different domains\workgroups.
        2. Remember that by default Scheduler service runs under the Local Sytem account.
        If the target machines are on different domains\workgroups you may not be able to use ScheduleAdd() remotely. You could try Win32::AdminMisc::LogonAsUser() but I am not sure how that works. In a worst case scenario, you may need to run the script once under the admin account for each domain\workgroup.

        Although these points probably aren't relevant to this question, I recommend setting up a seperate account for the scheduler service and only give it the permissions that your scheduled tasks need rather than all those that LocalSystem has by default.

        Error: Keyboard not attached. Press F1 to continue.

        Update: Sorry joe, this was meant as a reply to Ray.