Hello all,

I'm relatively new to perl, so please be kind :)

I'm trying to schedule some jobs on a bunch of win2k/2003 boxes.  I have
the following VBscript that I'm trying to convert to perl:

option Explicit
Dim objWMIService, objNewJob, errJobCreated, JobID

Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
errJobCreated = objNewJob.Create("Notepad.exe", _
                "********123000.000000-420", _
                True , 1 OR 4 OR 16, , , JobID) 
WScript.Echo JobID

This works fine: the job is created and the newly created job ID is
printed to the screen.

Here is my perl code:

use strict;
use Win32::OLE;

my( $objWMI, $objNewJob, $strError, $strJobID );
$objWMI = Win32::OLE->GetObject( "winmgmts:\\\\.\\root\\cimv2" );
$objNewJob = $objWMI->Get( "Win32_ScheduledJob" );
$strError = $objNewJob->Create('Notepad.exe', 
                '********123000.000000-420',
                1 , (1 + 2 + 4 + 8 + 16 + 32 +64), , ,\$strJobID);

print "JobID: $strJobID";

This almost works: the job is created, but the newly created job ID is
not in the $strJobID variable.  I tried messing with
Win32::OLE::Variant, but I don't seem to be getting far with that.

Here is a link to the MSDN doc I was using as a reference:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/
wmi/create_method_in_class_win32_scheduledjob.asp


Any help greatly appreciated.

Thanks,

Jeff

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to