Skip to content

Instantly share code, notes, and snippets.

@gpduck
Created September 13, 2013 01:59
Show Gist options
  • Save gpduck/6546064 to your computer and use it in GitHub Desktop.
Save gpduck/6546064 to your computer and use it in GitHub Desktop.
Start a process and manipulate stdin in PowerShell
try {
$MyProcess = New-Object System.Diagnostics.Process
$MyProcess.StartInfo.FileName = "c:\MyProcess.exe"
$MyProcess.StartInfo.Arguments = "arguments for process"
$MyProcess.StartInfo.UseShellExecute = $false
$MyProcess.StartInfo.RedirectStandardInput = $true
$MyProcess.Start()
$StdIn = $MyProcess.StandardInput
$StdIn.WriteLine("some data")
} finally {
if($StdIn) {
$StdIn.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment