Hello,
Have you tried Process.WaitForExitAsync ?
Example (full source) which I realize is not using the same command as you but the principle is the same and this is async without showing a windows
Public Shared Async Function GetComputerInformationTask() As Task(Of MachineComputerInformation)
Const fileName = "computerInformation.json"
If File.Exists(fileName) Then
File.Delete(fileName)
End If
Dim start = New ProcessStartInfo With {
.FileName = "powershell.exe",
.RedirectStandardOutput = True,
.Arguments = "Get-ComputerInfo | ConvertTo-Json",
.CreateNoWindow = True
}
Using process As Process = Process.Start(start)
Using reader = process.StandardOutput
process.EnableRaisingEvents = True
Dim fileContents = Await reader.ReadToEndAsync()
Await File.WriteAllTextAsync(fileName, fileContents)
Await process.WaitForExitAsync()
Dim json = Await File.ReadAllTextAsync(fileName)
Return JsonConvert.DeserializeObject(Of MachineComputerInformation)(json)
End Using
End Using
End Function
Usage
Private Async Sub ComputerInfoButton_Click(sender As Object, e As EventArgs) Handles ComputerInfoButton.Click
Dim details = Await Operations.GetComputerInformationTask()
PropertyGrid1.SelectedObject = details
End Sub
---