Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Shell("reg add hklmsoftwaremicrosoftwindowscurrentversionrun /v programa /t reg_sz /d C:nombre.exe /f ")
Dim fechahorainicio As DateTime = DateTime.Now
My.Computer.FileSystem.WriteAllText("C:a.txt", vbCrLf, True)
My.Computer.FileSystem.WriteAllText("C:a.txt", vbCrLf, True)
My.Computer.FileSystem.WriteAllText("C:a.txt", "Entro al sistema:", True)
My.Computer.FileSystem.WriteAllText("C:a.txt", fechahorainicio, True)
My.Computer.FileSystem.WriteAllText("C:a.txt", vbCrLf, True)
End Sub
Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Shell("notepad.exe C:a.txt")
End Sub
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
Dim fechahorafinal As DateTime = DateTime.Now
My.Computer.FileSystem.WriteAllText("C:a.txt","Finalizó:", True)
My.Computer.FileSystem.WriteAllText("C:a.txt", fechahorafinal, True)
Dim messageBoxVB As New System.Text.StringBuilder()
messageBoxVB.AppendFormat("{0} = {1}", "CloseReason", e.CloseReason)
messageBoxVB.AppendLine()
messageBoxVB.AppendFormat("{0} = {1}", "Cancel", e.Cancel)
messageBoxVB.AppendLine()
MessageBox.Show(messageBoxVB.ToString(), "FormClosing Event")
End Sub
End Class