vbs script that loops every 15 minutes until "OK" pressed

Greetings .VBS script guru's!

I'm trying to write a FOR loop that continually loops every 15 minutes (in the background) until the user clicks the "OK" button. If the user clicks the "cancel" button, then the VBS script will run in the backgroup and pop-up again every 15 minutes until the user clicks the "OK" button (which then performs an action). I've tried a DO, and WHILE and a FOR loop, without any success.

Any ideas how I could accomplish this?

Thank you so much for your expert assistance!

-Mac
TECHSANTAAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Bill PrewIT / Software Engineering ConsultantCommented:
So, for the 15 minutes of background processing you don't want anything on screen, right?

And then, each 15 minutes you will ask what they want to do, Okay to exit, or Cancel to go back to background mode?

How long do you want this choice dialog to stay visible?  Since it is a blocking even your script can't do anything else until they decide, so how long to you want to give them?

And what if they don't click a button, but rather that dialog times out after say 30 seconds.  What should the path be then?


»bp
Bill PrewIT / Software Engineering ConsultantCommented:
And is this really VBScript, or something else, like VB or VB Classic, etc?


»bp
TECHSANTAAuthor Commented:
Hi Bill

Thank you for your reply.

It's a script .vbs that runs on Windows 7 PC.

To answer your questions:

<<So, for the 15 minutes of background processing you don't want anything on screen, right?>>

Correct. Nothing on the screen, so that they can continue to work uninterrupted.

 <<And then, each 15 minutes you will ask what they want to do, Okay to exit, or Cancel to go back to background mode?>>

Yes, exactly. the pop-up will happen again and they have a choice of "OK" or "CANCEL". If they click "OK", then it performs an action. If they click "cancel" it goes into background mode again, waiting another 15 minutes to pop-up again.

<< How long do you want this choice dialog to stay visible? >> 

It should stay always stay visible until which time they either choose "OK" or "CANCEL"

<<Since it is a blocking even your script can't do anything else until they decide, so how long to you want to give them?>>

They have forever to decide, until which time they either click "OK" or "CANCEL", to move on.

<< And what if they don't click a button, but rather that dialog times out after say 30 seconds.  What should the path be then?>>

The pop-up dialog should not time out. I should stay up on their screen until they choose "OK" or "cancel", so it forces them to make a decision or they can't continue to work.

Thank you very much, Bill for your help with this!

-Mac
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Shaun VermaakTechnical SpecialistCommented:
Option Explicit

Dim Message

Do Until Message = vbOk 
    Message = MsgBox("Test",vbOKCancel,"Test")
    WScript.Sleep 900000
Loop 

Open in new window

Bill PrewIT / Software Engineering ConsultantCommented:
Give this a try, run from a command prompt using CSCRIPT EE29065540.vbs

' Flag to indicate when to end loop
blnDone = False

' Set time to prompt if they want to continue
'timAlarm = DateAdd("n", 15, Now())  '15 minutes from now
timAlarm = DateAdd("n", 1, Now())   '***** TESTING *****

Do Until blnDone

    ' Do a chunk of background work
    Call DoSomeWork()

    ' If it's been 15 minutes, ask what to do
    If Now > timAlarm Then

        ' Display message box, wait until they take action
        intReturn = MsgBox("Please select processing mode:" & vbCrLf & "CANCEL = Continue processing," & vbCrLf & "OKAY = End processing.", vbOkCancel, "Continue?")

        ' Did they click "OK" button?
        If intReturn = vbOK Then
            ' Yes, do OK processing, stop looping
            Call OkayProcessing
            blnDone = True
        Else
            ' No, reset alarm for 15 minutes from now
            timAlarm = DateAdd("n", 1, Now())
        End If

    End If

Loop

Sub DoSomeWork()
    Wscript.Echo Now() & " - DoSomeWork"     '***** TESTING *****
    Wscript.Sleep 10000                      '***** TESTING *****
End Sub

Sub OkayProcessing()
    Wscript.Echo Now() & " - OkayProcessing"     '***** TESTING *****
    Wscript.Sleep 10000                          '***** TESTING *****
End Sub

Open in new window


»bp

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TECHSANTAAuthor Commented:
Thank you very much! Trying it today. Will let you know how it works ASAP.
TECHSANTAAuthor Commented:
Outstanding. I'm good, but you blow me away. Great! Thank you!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.