troubleshooting Question

problem in setting task in windows scheduler using Win32_ScheduledJob

Avatar of retinax
retinax asked on
Operating SystemsVisual Basic Classic
2 Comments1 Solution1243 ViewsLast Modified:
i m using this code to set task in windows scheduler

'------------Code is here
Dim objWMIService As Object, objNewJob As Object
Dim ObjBias As Object, ObjItem As Object
Dim lJobId As Long
Dim errJobCreated  As Integer
Dim iBias As Integer

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set objNewJob = objWMIService.Get("Win32_ScheduledJob")

Set ObjBias = objWMIService.ExecQuery("Select * from Win32_TimeZone")
For Each ObjItem In ObjBias
    iBias = ObjItem.bias

errJobCreated = objNewJob.Create("C:\Documents and Settings\a\Desktop\Backup Manager\Backup Manager\Backup Manager.exe", "********" & Format(Hour(dtStartTime), "00") & Format(Minute(dtStartTime), "00") & Format(Second(dtStartTime), "00") & _
                ".000000+" & iBias, True, lDaysofWeek, lDaysofMonth, , lJobId)

this code sets the task but does not execute it

when i places my exe in C:\windows and uses create method like this it works fine

errJobCreated = objNewJob.Create("Backup Manager.exe", "********" & Format(Hour(dtStartTime), "00") & Format(Minute(dtStartTime), "00") & Format(Second(dtStartTime), "00") & _
                ".000000+" & iBias, True, lDaysofWeek, lDaysofMonth, , lJobId)

when i see properties of this  task it show "start in" value where as in my previous code it shows blank in "start in"

can u help me to set start in value programmatically preferablly in vb6
i think the problem is because it is not setting "start in" value
Éric Moreau
Senior .Net Consultant
Join our community to see this answer!
Unlock 1 Answer and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros