Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

scheduled job is not created

Status
Not open for further replies.

barny2006

MIS
Mar 30, 2006
521
US
i'm trying to schedule a job to run on wednesdays at 14:00.
i'm using the following code, but the job is not created on the scheduled jobs under system tools.
what could be the problem?

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

errJobCreated = objNewJob.Create _
("lead_backup.exe", "********123000.000000-420", _
True , 4, , , JobID)
 
but i can go system tools/schdule jobs and create jobs that can run at a certain time. is suppose, when using wmi stuff, it won't let me do it. am i correct on this?
 
Have you tried to not use impersonationLevel=impersonate ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
How do you know you have access to "lead_backup.exe" without absolute path? Is it within path?
 
tsuji,
i have access to lead_backup.exe. i can run it from windows via shortcut.
 
error code is still 2, even after taking out the impersonate part.
 
via shortcut to what??? i would try what tsuji suggests and put in a qualified path to your lead_backup.exe...just for arguments sake
 
mrmovie,
the program lead_backup.exe is in program files, and i have put a shortcut on the desktop. it runs ok.
i tried this code with calc.exe (windows calculator). it gives me the same error code.
the bottom line is that i can go to system tools and schedule a job via schedule wizard, but i can't use vb script and wmi to create a scheduled job. i'm puzzled.
 
I meant...

[tt]errJobCreated = objNewJob.Create _
("[blue]c:\program files\xyz\[/blue]lead_backup.exe", "********123000.000000-420", _
True , 4, , , JobID) [/tt]

If it is inside program files folder where normally be a lot of application subfolders, chances are it is not set in the environment variable path.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top