1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
' Permet de créer une chaine de caractère correspondant à un fichier script.bat dans le dossier temporaire
' de l'utilisateur courant
Dim path As String = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "PSVersion.ps1")
' Ecrit le contenu de la ressource "script" dans un nouveau fichier (créé s'il n'existe pas, remplacé s'il existe)
File.WriteAllBytes(path, My.Resources.PSVersion)
' Ouvre le fichier bat avec le programme par défaut
'Process.Start("powershell", path)
RedirectStandardOutput = True
Dim myStreamReader As StreamReader = Process.Start("powershell", path).StandardOutput
' Read the standard output of the spawned process.
Dim myString As String = myStreamReader.ReadLine()
TextBox1.Text = myString
End Sub
End Class |
Partager