Hi all,
Does anybody know how I can put a program running at a specific time everyday (from Monday to Friday)?
Thanks in advance.
Printable View
Hi all,
Does anybody know how I can put a program running at a specific time everyday (from Monday to Friday)?
Thanks in advance.
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. :D
Kinjal
It's a good ideia, bur how can I make that program that is always running hidden?
Do you have any example of it?
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:
Public Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal Hkey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Public Declare Function RegCloseKey Lib "advapi32.dll" (ByVal Hkey As Long) As Long 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 Public Const REG_SZ = 1 ' Unicode nul terminated String Public Const REG_DWORD = 4 ' 32-bit number Public Const HKEY_LOCAL_MACHINE = &H80000002 Private sub Form_load() Call savestring(HKEY_LOCAL_MACHINE, "Software\Microsoft\Windows\Currentversion\Run", "Your_key_name", "EXE1_Path.exe") End Sub Public Sub savestring(Hkey As Long, strPath As String, strValue As String, strData As String) Dim keyhand As Long Dim r As Long r = RegCreateKey(Hkey, strPath, keyhand) r = RegSetValueEx(keyhand, strValue, 0, REG_SZ, ByVal strData, Len(strData)) r = RegCloseKey(keyhand) 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.
:D Hope this helps
Kinjal