WScript in vbscript activex task

  • Hello

    I can use the Wshell wsh object by instantiating it with the command below;

    Set WshShell = CreateObject("WScript.Shell")

    and then use the run method using WshShell.Run

    I need to do the same with WScript.Sleep to get a package to wait for 5 mins between looks for a file but you can't instantiate WScript in order for it work in the same way.

    I don't really want to do it like;

    Do

    Loop Until fsoDataPopulation.FileExists(strSourceFile)

    as this hammers the cpu unitil the file arrives.

    I may be missing something really easy here but is there away I can get my task to 'wait'(vbscript) or get WScript to work within the activex script?

    thanks

  • Maybe I'm missunderstanding this but why do you have to wait? Can't you create a dependency on the creation of the file and the step that needs the file? Using an "On success" work flow property?

    Darren

    Darren


    Darren

  • I want to check if the flag file exists. If it does then do processing. If not then sleep for 5mins then check again rather than continually looking for the flag file as it can be waiting for a considerable time.

    something like the below (which is fine in .vbs script)

    loopnumber =1

    While loopnumber =1

    if fs.FileExists(strSourceFile) Then

    do processing in here

    Main = DTSTaskExecResult_Success

    loopnumber =2

    else

    WScript.Sleep(300000)

    end if

    Wend

  • The other way to wait in VB is to loop using a timer. You should be able to find examples in help. You loop while a certain time elapses, then exit the loop and check for the file. Just make sure you use DoEvents to check for other events triggered.

    Darren


    Darren

  • If you loop on a timer then isn't this the same as looping until file exists, the cpu is still active.

    Ideally I'd like to use WScript.Sleep or something similar from inside the activex task.

    thanks

  • Hi,

    I am trying to do exactly the same thing from DTS...

    ..Look for a file..if its there continue...Else...wait 5 mins and look again

    Im also trying to do this in DTS package. Did you ever have any luck with it

     

    Any help greatly appreciated

    Thanks

    Jimmy

  • Try taking advantage of SQL jobs.

    We did the same you are trying to do like this.

    Set up a Job with say 2 steps.

    Step 1 searches for that file, if it is found goto step 2, otherwise try again in 5 minutes.

    Step 2 Do what ever you need to with the file.

     

    There are some more advanced ways with rescheduling the job from within itself but sounds like the first approach should solve what you are trying to do.

     

     

  • If you are planning to to the Job path make sure whatever is run from the job is DONE before Next job iteration because Jobs are NOT reentrant!!

    HTH

     


    * Noel

Viewing 8 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic. Login to reply