Results 1 to 2 of 2

Thread: [RESOLVED] use variable in objNewJob.Create

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    5

    Resolved [RESOLVED] use variable in objNewJob.Create

    Hello everyone,

    I am building an application that allows several different people to schedule tasks on a server. It needs to be able to schedule the task on different days of the week. The following code works:

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
    errJobCreated = objNewJob.Create _
    ("C:\Programming\VB6\operations\sendouts\" & Combo1.text & "\send.bat", "****0801" & Mid(cboTime, 1, 2) & Mid(cboTime, 4, 2) & "00.000000-420", _
    True, 1 Or 2, , , jobId)

    When I change the '1 or 2' and replace it with a string variable:

    Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    Set objNewJob = objWMIService.Get("Win32_ScheduledJob")
    errJobCreated = objNewJob.Create _
    ("C:\Programming\VB6\operations\sendouts\" & Combo1.text & "\send.bat", "****0801" & Mid(cboTime, 1, 2) & Mid(cboTime, 4, 2) & "00.000000-420", _
    True, dayList, , , jobId)

    where dayList = "1 Or 2" I get a type mismatch error (take it doesn't like it being a string). I can see the mismatch, but can not find out what to cast this to in order to allow the code to work the way I would like it to (or if it is possible).

    Can anyone provide any help?

    Thanks in advance.

  2. #2

    Thread Starter
    New Member
    Join Date
    Jul 2007
    Posts
    5

    Re: use variable in objNewJob.Create

    After days of searching, I found the answer. By setting the variable dayList to int (instead of string as I had it) you can solve this problem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width