Click here to Skip to main content
11,703,505 members (69,241 online)
Click here to Skip to main content

Program Executer Timer

, 17 Jan 2006 63.1K 376 34
Rate this:
Please Sign up or sign in to vote.
A program to execute any EXE, then close it after a specified span of time.

Introduction

This article describes implementing something like the scheduled tasks for Windows, in a Web application, and this can be used without permissions from the administrator.

Background

I was working on an ASP.NET application and they required me to solve a problem of calling a web page at 12:00 PM everyday to do something.

Using the code

It's very simple. It uses a file placed on c:\named uRL.txt.

This file describes what a program will do, and other details, like:

In this example:

  • NotePad.exe, is the application you want to invoke. It could be "Explorer" or "Internet Explorer" or whatever program you want to open.
  • The second parameter here is the file to open: c:\Mytestfile.txt. It could be a URL like this: http://MySite.com, if you want IE to open it for you.
  • 36000 - this is the time interval in seconds, 36000 if you want it to check each hour.
  • 17 - this is the start time specified in a 24 hour clock.
  • 12000 - this is the time to wait to close the program.
' this line to execute the program placed
' on the c:\URL.txt (Notepad.exe) on this example 
Process.Start(strProgramName,strURL)

' this Function to kill the process
Function Kill()
    Dim IE As System.Diagnostics.Process()
    IE = Process.GetProcessesByName(strProgramName)
    Dim i As Integer
    Dim IE1 As System.Diagnostics.Process
    For i = 0 To IE.Length - 1
        'end 
        IE1 = IE.GetValue(i)
        IE1.Kill()
    Next
End Function

' And this function to check if we are
' in time to execute the program ?

Function checker() As Boolean
    Dim currentHour As Integer = DateTime.Now.Hour
    If currentHour >= Integer.Parse(strDailyInterval) _
           And currentHour < Integer.Parse(strDailyInterval) + 1 Then
        checker = True
    Else
        checker = False
    End If
End Function

Points of Interest

It can be used in an ASP.NET application, or for remotely controlling PCs on a LAN. Place the URL.txt at any path, then you can load whatever site, or execute any program on the remote PC.

History

Hope you like it. I will be glad to see your comments in the forum below Smile | :) .

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Tareq_Gamal
Egypt Egypt
Tareq Gamal el-din Mohammed ,
Finalized the Study of Computer education at Modern Academy at Egypt ,
Then had many Microsoft Official Certificates like:
MCAD.NET (Microsoft Certified Application Developer)
MCSD.NET (Microsoft Certified Solution Developer)
Also others for SharePoint from some private sector education centers.

Robotics fields was a Hobby since 2002 ,
started to develop some applications for "RoboSapien","RS Media" ,and RoboMe. from Wowwee company,

after that started working with robots as professional way. at 2014
By using "NAO" Robot from Aldebaran.

By developing some applications and libraries like :
NAO.NET.
https://www.youtube.com/watch?v=oOyy-2XyT-c

OpenCV with NAO Robot:

- NAORobot Vision using OPENCV -TotaRobot P1
https://www.youtube.com/watch?v=MUcj8463x08

- NAO Robot Vision using OPENCV - P2
https://www.youtube.com/watch?v=93k1usaS-QM

NAO Alarm Clock :
https://www.youtube.com/watch?v=djLlMeGLqOU
-----------------------------

Other Projects Developed by Tareq Gamal El-din Mohammed :

Developed and posted some applications in Code Project web site like :

- Control your Distributed Application using Windows and Web Service
http://www.codeproject.com/Articles/101895/Control-your-Distributed-Application-using-Windows

- Quick and dirty directory copy
http://www.codeproject.com/Articles/12745/Quick-and-dirty-directory-copy

- Program Execute Timer(From the Web)
http://www.codeproject.com/Articles/12743/Program-Executer-Timer

details in the other account :

Tareq_Gamal
http://www.codeproject.com/script/Membership/View.aspx?mid=2619758

You may also be interested in...

Comments and Discussions

 
GeneralUpdated Version: Pin
Tareq_Gamal8-Nov-06 10:13
memberTareq_Gamal8-Nov-06 10:13 
QuestionSource Code link broken.... Pin
TheQuank23-Jun-06 4:47
memberTheQuank23-Jun-06 4:47 
AnswerRe: Source Code link broken.... Pin
tareqGamal7-Jul-06 4:43
membertareqGamal7-Jul-06 4:43 
Generalsource upload Pin
Tareq_Gamal26-Jan-06 3:59
memberTareq_Gamal26-Jan-06 3:59 
GeneralWhy it did not kill process Pin
jpazgier25-Jan-06 0:36
memberjpazgier25-Jan-06 0:36 
GeneralRe: Why it did not kill process Pin
Tareq_Gamal26-Jan-06 3:43
memberTareq_Gamal26-Jan-06 3:43 
GeneralRe: Why it did not kill process Pin
jpazgier26-Jan-06 5:11
memberjpazgier26-Jan-06 5:11 
GeneralRe: Why it did not kill process Pin
tareqGamal27-Jan-06 12:42
membertareqGamal27-Jan-06 12:42 
GeneralRe: Why it did not kill process Pin
tareqGamal27-Jan-06 13:12
membertareqGamal27-Jan-06 13:12 
GeneralRe: Why it did not kill process Pin
jpazgier28-Jan-06 3:49
memberjpazgier28-Jan-06 3:49 
GeneralIt starts a process but doesn't kill it Pin
jerryoz24-Jan-06 22:44
memberjerryoz24-Jan-06 22:44 
GeneralRe: It starts a process but doesn't kill it Pin
Tareq_Gamal26-Jan-06 3:53
memberTareq_Gamal26-Jan-06 3:53 
GeneralRe: It starts a process but doesn't kill it Pin
tareqGamal1-Feb-06 0:52
membertareqGamal1-Feb-06 0:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150819.1 | Last Updated 17 Jan 2006
Article Copyright 2006 by Tareq_Gamal
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid