-
-
Save Sjark/dcb3575eca3720f6f7101ca7e67dc39e to your computer and use it in GitHub Desktop.
Start a process and manipulate stdin in PowerShell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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