Skip to content

Instantly share code, notes, and snippets.

@gpduck
Created September 13, 2013 01:59
Embed
What would you like to do?
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