Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Monitoring if process has finished in VBS (WinXP/VBS)

    I'm running a VBS script (from Task Scheduler) and want to show a message while the program is still running. When finished, I want to replace the "Running" message with a "Finished" message and have that disappear automatically

    Here's a part of my script:

    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonat e}!.rootcimv2")
    Set objStartup = objWMIService.Get("Win32_ProcessStartup")
    Set objConfig = objStartup.SpawnInstance_
    objConfig.PriorityClass = intPriority
    Set objProcess = GetObject("winmgmts:rootcimv2:Win32_Process")
    objProcess.Create strExecutable, Null, objConfig, intProcessID

    Here, in "strExecutable" is my program specified.

    Any suggestions?

    Thanks!!

    Erik Jan

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Monitoring if process has finished in VBS (Win

    The way I would do this is by using a Do loop which performs a test with a time delay each time. An example is shown below.
    Do While (objApplication.Busy)
    Wscript.Sleep 200
    Loop
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Monitoring if process has finished in VBS (Win

    Thanks, but 'objApplication.Busy' doesn't seem to work here. I do have the processID ("intProcessID") from the call, assume I should use that somehow... but how ?

  4. #4
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Monitoring if process has finished in VBS (Win

    On request, I'm moving this question to this thread (I had separated for clarity as these are different questions, one is scripting, the other is application communication to task-scheduler) but of course I'm perfectly OK to place this here. For clarity, I'll repeat my question below:



    I have a small VBS script that I've placed in the Task Scheduler to allow it to be executed e.g. daily.

    Is there a way to 'control' the Status field in the scheduler from my App? Next to the obvious things like "Running" etc. I'd like to put there things like "Successfull" and/or "Error" so users can see if the scheduled task worked OK.

    Any ideas?

    Erik Jan

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Monitoring if process has finished in VBS (Win

    I'm not sure I understand - doesn't the Task Scheduler show you the status anyway? There is a Task Scheduler API but I don't know whether this allows you to change the returned status, or merely create scheduled tasks. I suspect that the scheduler simply takes the return code provided by whatever program was scheduled to run.
    Regards,
    Rory

    Microsoft MVP - Excel

  6. #6
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Monitoring if process has finished in VBS (Win

    In the scheduler window (where all tasks are listed 'Scheduled Tasks'), I see a "Status" and a "Last Result" column. I was wondering if I can control what is displayed in e.g. the status field after my application has ended (e.g. by returning an error-code or string).

    I see sometimes that other Apps do that: the "Last Result" field has several entries <>0 and sometimes the "Status" field has text

  7. #7
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: Monitoring if process has finished in VBS (Win

    Are you creating a log file of the status results or do you only want to store the status of the last run?

    Have you seen this web page http://www.15seconds.com/issue/980513.htm which appears to give information about where the Task Scheduler gets its information from and how to program it in ASP. Does that page give you something to start on?
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  8. #8
    5 Star Lounger
    Join Date
    Jul 2001
    Location
    Terneuzen, Netherlands
    Posts
    895
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Monitoring if process has finished in VBS (Win

    I want to store the status so I can check later if the task was executed successfully or not

    Thanks for the link! I looked there and tried to copy copy very simple stuff into a VBS file but couldn't get it to work. I do apologize, I'm pretty knowledgeable in VB(A) but ver ignorant in VBS, WshShell, CSCRIPS, ASP... it's all fuzzy to me...

    If I can do the basic tasks, my VB(A) knowledge will get me there; starting things up is a mess however. See also my other threads on how to display a text on screen without user-interfacing; I searched the internet and newsgroups but have found nothing to date. Also questions on how I can see when my task has ended remain unanswered. Maybe it is difficult and/or not possible afterall.

    It's not really crucial; I can work around it if I need to.

    Do appreciate all the help and hints and tips I'm getting: I'm learning <img src=/S/bow.gif border=0 alt=bow width=15 height=15>

Posting Permissions

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