Skip to content

Instantly share code, notes, and snippets.

@grmartin
Created October 22, 2015 16:32
Show Gist options
  • Save grmartin/9524d2302f9e78587e65 to your computer and use it in GitHub Desktop.
Save grmartin/9524d2302f9e78587e65 to your computer and use it in GitHub Desktop.
function Invoke-Batch {
param (
[Parameter(Mandatory=$True)]
[String] $BatName
)
$psi = New-object System.Diagnostics.ProcessStartInfo
$psi.CreateNoWindow = $true
$psi.UseShellExecute = $false
$psi.RedirectStandardOutput = $true
$psi.RedirectStandardError = $true
$psi.FileName = "cmd.exe"
$psi.Arguments = @("/c $BatName")
$process = New-Object System.Diagnostics.Process
$process.StartInfo = $psi
[void]$process.Start()
$x = $process.StandardOutput.ReadToEnd()
$process.WaitForExit();
return $x
}
Set-Alias Call Invoke-Batch
Set-Alias ibat Invoke-Batch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment