Results 1 to 4 of 4

Thread: Schedule

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Lisbon, Portugal
    Posts
    69

    Question Schedule

    Hi all,

    Does anybody know how I can put a program running at a specific time everyday (from Monday to Friday)?

    Thanks in advance.
    Rita Jaques

  2. #2
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    The simplest idea is to make 2 exes out of which one is always running hidden after the system starts. This exe will keep a track of time and will use ShellExecute API to run the other exe at desired time.

    Kinjal

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2001
    Location
    Lisbon, Portugal
    Posts
    69

    Question

    It's a good ideia, bur how can I make that program that is always running hidden?

    Do you have any example of it?
    Rita Jaques

  4. #4
    Fanatic Member kinjalgp's Avatar
    Join Date
    Apr 2000
    Location
    India
    Posts
    535
    To run a program as soon as the windows starts you have to place it in the system registry in "HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\Currentversion\Run" key.

    Example:
    VB Code:
    1. Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
    2. Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long
    3. Public Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal Hkey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
    4.  
    5. Public Const REG_SZ = 1 ' Unicode nul terminated String
    6. Public Const REG_DWORD = 4 ' 32-bit number
    7. Public Const HKEY_LOCAL_MACHINE = &H80000002
    8.  
    9. Private sub Form_load()
    10. Call savestring(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\Currentversion\Run", "Your_key_name", "EXE1_Path.exe")
    11. End Sub
    12.  
    13. Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strData As String)
    14.     Dim keyhand As Long
    15.     Dim r As Long
    16.     r = RegCreateKey(Hkey, strPath, keyhand)
    17.     r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData))
    18.     r = RegCloseKey(keyhand)
    19. End Sub

    To make a exe invisible make the Visible property of the main Form to false.

    The above code should be placed in your 2nd Exe and it should be run atleast once before the scheduling starts on regular basis.

    Hope this helps

    Kinjal
    Last edited by kinjalgp; Sep 4th, 2002 at 12:00 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width