Hello, I'm trying to write a simple little TAsk Schedulaer app

When my lable caption timer hits a certian time It's supposed to load a program

If lblTime.Caption = "9:11:25 AM" Then
fullpath = "C:\windows\notepad.exe"
iTask = Shell(fullpath, vbNormalFocus)
pHandle = OpenProcess(SYNCHRONIZE, False, iTask)
'ret = WaitForSingleObject(pHandle, INFINITE)
'ret = CloseHandle(pHandle)
End If


However this opens 6 instances of notepad! and i only want it to open one... I'm not really sure what those last two things:waitforsingleobject, and closehandle do so i just commented them out.

Please help i'll be in the IRC if someone needs more info.

Thanks

-edit: Perhaps it has something to do with timer interval?

dim flag as Boolean

Private Sub Form_Load()
   ' set flag to false when app starts
   ' I think it defaults to false. Just in case.
   flag = False
End Sub



' Your code.....

If lblTime.Caption = "9:11:25 AM" and Flag = False Then
   flag = True
   fullpath = "C:\windows\notepad.exe"
   iTask = Shell(fullpath, vbNormalFocus) 
   pHandle = OpenProcess(SYNCHRONIZE, False, iTask)
   'ret = WaitForSingleObject(pHandle, INFINITE)
   'ret = CloseHandle(pHandle)
End If

If lblTime.Caption = "9:11:30 AM" then
   ' reset flag for next day
   flag = False
endif

code looks solid i'm sure it will work!

btw do you have any idewa what the
'ret = WaitForSingleObject(pHandle, INFINITE)
'ret = CloseHandle(pHandle)
arre for?

This article has been dead for over six months. Start a new discussion instead.