Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Timer1.Start()
Try
My.Computer.FileSystem.DeleteFile("result_cmd.txt")
Catch ex As Exception
End Try
Try
My.Computer.FileSystem.DeleteFile("commande.bat")
Catch ex As Exception
End Try
Try
Dim sw As StreamWriter
sw = File.CreateText("commande.bat")
sw.WriteLine("@echo off")
sw.Flush()
sw.Close()
Dim kl = My.Computer.FileSystem.GetFileInfo("commande.bat")
Dim pp = kl.DirectoryName
sw = File.AppendText("commande.bat")
sw.WriteLine("dir c:\temp > " + pp + "\result_cmd.txt")
sw.Flush()
sw.Close()
Catch ex As Exception
End Try
Try
Dim startInfo As New ProcessStartInfo("commande.bat")
startInfo.WindowStyle = ProcessWindowStyle.Minimized
Process.Start(startInfo)
Catch ex As Exception
End Try
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
If File.Exists("result_cmd.txt") = True Then
Try
Dim SR As New StreamReader("result_cmd.txt")
TextBox1.Clear()
TextBox1.Text = SR.ReadToEnd
SR.Close()
My.Computer.FileSystem.DeleteFile("commande.bat")
My.Computer.FileSystem.DeleteFile("result_cmd.txt")
Timer1.Stop()
Catch ex As Exception
End Try
End If
End Sub