整个程序是这样的:
Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
Dim strhh, systemhour, systemminute, systemsecond As String
Dim h1 As Integer
Dim strPath As String
Dim line1, line2 As String
Dim hour1, minute1 As String
Dim hour2, minute2 As String
Dim ProcID As Integer
strhh = TimeString '系统时间:如:15:25:45
systemhour = Mid(strhh, 1, 2)
systemminute = Mid(strhh, 4, 2)
systemsecond = Mid(strhh, 7, 2)
'读入启动系统的时间
strPath = System.Windows.Forms.Application.StartupPath
Dim file1 As System.IO.StreamReader = New System.IO.StreamReader(strPath & "\BootTime.txt")
line1 = file1.ReadLine() ' "11:50"
line2 = file1.ReadLine()
file1.Close()
hour1 = Mid(line1, 2, 2)
minute1 = Mid(line1, 5, 2)
hour2 = Mid(line2, 2, 2)
minute2 = Mid(line2, 5, 2)
'判断是否到启动的时间
'TextBox1.Text = systemhour
'ProcID = 0
TextBox1.Text = ProcID
If (systemhour = hour1 And systemminute = minute1) Or (systemhour = hour2 And systemminute = minute2) Then
If systemsecond = "01" then
ProcID = Shell(strPath & "\notepad.exe", AppWinStyle.NormalFocus, True, 1)
End If
End If
End Sub