You can use WMI, here's a snippet:

use Win32::OLE qw(in);

my $machine = ".";
my $path = "WinMgmts:{impersonationLevel=impersonate}!//$machine/root/cimv2";

if (my $WMI = Win32::OLE->GetObject($path))
{

    my $Results = $WMI->ExecQuery("SELECT DisplayName,State FROM Win32_Service");

    foreach $service (in sort $Results)
    {
        if ( $service->DisplayName=~/whatever process/i )
        {
            print $service->DisplayName;
            do_action("START",$service);
        }
    }
}

sub do_action
{
    my ($action,$ServiceInst) = @_;
    if ($action="">
    {
        my $Result = $ServiceInst->StartService();
        if ($Result == 0)
        {
            print_this(",Started ".$service->DisplayName,", Started ".$service->DisplayName,0);
        }
        elsif ($Result == 10)
        {
            print_this(",Already Started ".$service->DisplayName,", Already Started ".$service->DisplayName,0);
        }
        else
        {
            print_this(",Cannot Start ".$service->DisplayName,", Cannot Start ".$service->DisplayName,1);
        }
    }
    elsif ($action="">
    {
        my $Result = $ServiceInst->StopService();
        if ($Result == 0)
        {
            print_this(",Stopped ".$service->DisplayName,", Stopped ".$service->DisplayName,0);
        }
        elsif ($Result == 5)
        {
            print_this(",Already Stopped ".$service->DisplayName,", Already Stopped ".$service->DisplayName,0);
        }
        else
        {
            print_this(",Cannot Stop ".$service->DisplayName,", Cannot Stop ".$service->DisplayName,1);
        }
    }
}

Regards,

Sam








"Chris Cappelletti" <[EMAIL PROTECTED]>

Sent by:
[EMAIL PROTECTED]

04/20/05 03:05 PM

       
        To:        <[email protected]>
        cc:        (bcc: Sam Dela Cruz/SVL/SC/PHILIPS)
        Subject:        RE: Starting process on remote machine

        Classification:        




>Anyway, the original question is still pending - any chance someone can
>point me at a module, script or code snippet that will let me launch a
>remote process as described in the original email?

Using the service idea you should be able to remote install a service on
whatever box you want it to run on (assuming the box has an os that
supports services) and make the service start outlook and stop outlook
and do the time measurements.  I have no clue how to do it in perl
though.


_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to