Run executable

  • In PowerShell is several ways how to run executable, here are some (not all) of them.

[Diagnostics.Process] Start()

$process= New-Object System.Diagnostics.Process
$process.StartInfo.Filename = "ping"
$process.StartInfo.Arguments = "8.8.8.8"
$process.StartInfo.RedirectStandardOutput = $True
$process.StartInfo.UseShellExecute = $False
$process.start()
#$process.Kill() # kills the process
$process.WaitForExit();
[string] $stdOut = $process.StandardOutput.ReadToEnd();

Start-Process

$process = Start-Process ping -ArgumentList "8.8.8.8" -wait -NoNewWindow -PassThru
$process.HasExited
$process.ExitCode

cmd

cmd /c ping 8.8.8.8

Sources

programming/powershell/runexecuable.txt · Last modified: 2018-06-21 19:48 (external edit)
CC Attribution-Noncommercial-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0