Computing.Net > Forums > Programming > Timer with pop-up reminders -vbs

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Timer with pop-up reminders -vbs

Reply to Message Icon

Name: cpete
Date: August 5, 2008 at 22:44:16 Pacific
OS: xp
CPU/Ram: 1g
Product: dell
Comment:

I am doing work in a lab where I record the time of my experiments and I need to see reminders while I wait for the process to complete.

I need to make/find a count up timer application that displays message boxes at given time intervals. I also need it to record start and stop times to a spreadsheet. Researching the problem, I think a simple vbs script would work well. Once I have the script, I know enough to customize to my needs. However, I don't know how to put this together from scratch.

Chris Peterson



Sponsored Link
Ads by Google

Response Number 1
Name: Hans Henrik
Date: August 7, 2008 at 00:20:36 Pacific
Reply:

this might help..

first off, remember that you can *-/+- etc
like
5*60 << 5 minutes
5*3600 << 5 hours

@echo off
cls
:sets
set /A SleepTime=
rem in secounds how long to sleep?
set /A TimeToStop=
rem how long shal i run be4 killing myself?
set /A TotalTime=0
set Fi=C:\TimeToStop.bat
set CW=C:\CreateWarning.bat
rem added that to make the bat smaller
:first
if exist %Fi% del %Fi%
echo @echo off>>%Fi%
echo "C:\Sleep.exe" %TimeToStop%>>%Fi%
echo Taskkill /IM Sleep.exe /F>>%Fi%
echo Taskkill /IM cmd.exe /F>>%Fi%
start %Fi%
:begin
"C:\Sleep.exe" %SleepTime%
set /A TotalTime=%TotalTime%+%SleepTime%
title been sleeping for %TotalTime% now
:CreateWarninig
if exist %CW% del %CW%
echo title Warning>>%CW%
echo @echo off>>%CW%
echo cls>>%CW%
echo echo Warning, have been sleeping for %TotalTime%
echo echo its %SleepTime% since last time you saw this.>>%CW%
echo pause>>%CW%
start %CW%
goto begin

you will be needing this Sleep program tho http://www.computerhope.com/dutil.htm

(direct link: http://www.computerhope.com/downloa... and sorry but i don't know VBS scripting but.. no1 else was answering this 1 so.. thought id give it a shot)


0

Response Number 2
Name: Razor2.3
Date: August 12, 2008 at 00:30:42 Pacific
Reply:

It's not what I'd categorize as simple, but this is probably what you're looking for:

Option Explicit
Dim shell, log, dateTime
Dim WMI, opts, PID, proc, ref, e

const cmd = "notepad.exe"
const startDir = "C:\windows\system32"
const logPath = "C:\log.csv"
Set shell = CreateObject("WScript.Shell")
Set WMI = GetObject("winmgmts:root\cimv2")
Set dateTime = CreateObject("WbemScripting.SWbemDateTime")
Set log = CreateObject("Scripting.FileSystemObject") _
.OpenTextFile(logPath, 8, True)

'Start watched process
'Reference: http://msdn.microsoft.com/en-us/library/aa394375(VS.85).aspx
Set opts = WMI.Get("Win32_ProcessStartup").SpawnInstance_
With opts
.CreateFlags = &H4000008 'Detached_Process + Create_Default_Error_Mode
.PriorityClass = 32 'Normal
.ShowWindow = 1 'Normal
End With

e = WMI.Get("Win32_Process").Create(cmd, startDir, opts, PID)
If e <> 0 Then
Dim str : str = "ERROR #" & e
Select Case e
Case 2 str = str & ": Access Denied"
Case 3 str = str & ": Insufficient Privllege"
Case 8 str = str & ": Unknown Failure"
Case 9 str = str & ": Not Found: " & cmd
Case 21 str = str & ": Script screwed up"
End Select
WScript.Echo str
WScript.Quit e
End If

'Start looking for the death of our process.
set ref = WMI.ExecNotificationQuery("SELECT * " _
& "FROM __instancedeletionevent " _
& "WITHIN 5 " _
& "WHERE TargetInstance ISA 'Win32_Process' "_
& "AND TargetInstance.ProcessID = " & PID)

'Make sure the process is still out there.
'(If not, we've already failed to catch its end.)
'Note: This is a very ungraceful crash. Expect a cryptic (WMI) error.
' Basically, if you get an error refering to line... 48(-ish?), this failed
Set proc = WMI.InstancesOf("Win32_Process")("Win32_Process=""" & PID & """")

shell.Popup "Started: " & cmd, 5 '5 second popup

'Yeah...
'When NextEvent times out, it'll raise an Error. We catch it, show a popup,
'unraise the event, and loop.
On Error Resume Next
Do
If Err.Number Then
'Popup for 5 seconds
shell.Popup "Still waiting...", 5, "Bored Now"
Err.Clear 'Reset Err.
End If
Set proc = ref.NextEvent(10000) 'Wait period is in milliseconds
Loop While Err = &H80043001 'wbemErrTimedOut
'Error handling off.
On Error GoTo 0

'Output to .csv
'Note: dateTime's functionallity changes, depending on your version of WinXP.
' If the times are off by a few hours, swap the Trues and Falses.
dateTime.Value = proc.TargetInstance.CreationDate
log.Write dateTime.GetVarDate(True) & ","

dateTime.SetFileTime proc.TIME_CREATED, False
log.WriteLine dateTime.GetVarDate(True)

WScript.Echo "Done!"



0

Response Number 3
Name: cpete
Date: August 20, 2008 at 21:26:23 Pacific
Reply:

Thank you! I work with these to get them to work for me.

chris peterson

Chris Peterson


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Timer with pop-up reminders -vbs

how to cover pop-up ad with my page?? www.computing.net/answers/programming/how-to-cover-popup-ad-with-my-page/2773.html

What's Up With All The VB www.computing.net/answers/programming/whats-up-with-all-the-vb/7089.html

Pop-Up IE Browser window w/VBScript www.computing.net/answers/programming/popup-ie-browser-window-wvbscript/6613.html