irsoy
Messages postés18Date d'inscriptionmercredi 7 février 2007StatutMembreDernière intervention 4 juillet 2008
-
10 mars 2007 à 17:01
irsoy
Messages postés18Date d'inscriptionmercredi 7 février 2007StatutMembreDernière intervention 4 juillet 2008
-
5 août 2007 à 19:28
Slt mes amis,
Ce que je veut, c'est que doi'je faire pour executer et arreter un programme dans un intervalle de temps comme le planificateur de tache de windows.
Exemple: Demarrer et arreter MyApp.exe chaque 15 minute
Merci pour vos aide.
Cardinalement.
-----------------------------------------------
En Informatique, tout est possible...
mais...
A+
ad vitam aeternam
Messages postés17Date d'inscriptionjeudi 19 mai 2005StatutMembreDernière intervention10 mars 2008 10 mars 2007 à 17:20
Salut!
Deux idées: Soit tu mets effectivement MyApp.exe dans le planificateur des tâches, soit tu utilise une sorte de timer: - dans MyApp un timer lance, toutes les 15 minutes la routine désirée.
- dans un autre programme touours ouvert tu met seulement un timer donc le but est de lancer MyApp.exe toutes les 15 minutes puis de fermer l'application MyApp.exe toutes les 15 minutes.
irsoy
Messages postés18Date d'inscriptionmercredi 7 février 2007StatutMembreDernière intervention 4 juillet 2008 5 août 2007 à 19:28
-- INTERFACE --
2 Boutons
1 Progress bar
1 NumericUpDown
1 Label
-- CODE --
Imports System
Imports System.Text
Public Class Frm_Planif
Dim oldtime$ = ""
Dim AppName$ = ""
Private Sub Frm_Planif_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
StopApplication(Mid(Txt_App.Text, 1, Txt_App.TextLength - 4))
End Sub
Private Sub Frm_Planif_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
oldtime = My.Computer.Clock.LocalTime.Minute
Lbl_Timer.Text = ""
With Progress
.Minimum = 1
.Maximum = (59 * Nm_Minute.Value)
.Step = Nm_Minute.Value
.Value = 1
End With
Me.Refresh()
End Sub
Private Sub StopApplication(ByVal app$)
Dim processList() As Process
processList = Process.GetProcessesByName(app)
For Each proc As Process In processList
proc.Kill()
Next
End Sub
Private Sub StartApplication(ByVal app$)
Process.Start(app)
End Sub
Private Sub Btn_Start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Btn_Start.Click
StartApplication(Txt_App.Text)
'
Btn_Start.Enabled = False
Bt_Stop.Enabled = True
Txt_App.Enabled = False
Nm_Minute.Enabled = False
'
With PlanifTime
.Interval = 1000
.Enabled = True
.Start()
End With
End Sub
Private Sub PlanifTime_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PlanifTime.Tick
Lbl_Timer.Text = "Il Reste [ " & (59 * Nm_Minute.Value) - My.Computer.Clock.LocalTime.Second & " ] secondes pour le prochain redemarrage"
Progress.Value += 1
'
If My.Computer.Clock.LocalTime.Minute - oldtime = Nm_Minute.Value Then
StopApplication(Mid(Txt_App.Text, 1, Txt_App.TextLength - 4))
Progress.Value = 1
oldtime = My.Computer.Clock.LocalTime.Minute
Lbl_Timer.Text = "Pause 5 Secondes . . ."
Me.Refresh()
Threading.Thread.Sleep(5000)
StartApplication(Txt_App.Text)
End If
End Sub
Private Sub Txt_App_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Txt_App.TextChanged
AppName = Mid(Txt_App.Text, 1, Txt_App.TextLength - 4)
End Sub
Private Sub Bt_Stop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Bt_Stop.Click
PlanifTime.Stop()
StopApplication(Mid(Txt_App.Text, 1, Txt_App.TextLength - 4))
Btn_Start.Enabled = True
Bt_Stop.Enabled = False
Txt_App.Enabled = True
Nm_Minute.Enabled = True
Progress.Value = 1
Lbl_Timer.Text = "Application Arretée .."
End Sub
Private Sub Nm_Minute_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Nm_Minute.ValueChanged
With Progress
.Minimum = 1
.Maximum = (59 * Nm_Minute.Value)
.Step = Nm_Minute.Value
.Value = 1
End With
End Sub
End Class
-----------------------------------------------
En Informatique, tout est possible...
mais...
A+