1
我有powershell進程,我打開啓動進程或System.Diagnostic.Process以不同的用戶身份啓動子進程(獲取其他用戶環境變量)將子進程的輸出重定向到父進程 - Powershell
我嘗試使用redirectoutput但它不起作用。下面是代碼
$process = New-Object System.Diagnostics.Process
$startinfo = New-Object "System.Diagnostics.ProcessStartInfo"
$startinfo.FileName = "powershell"
$startinfo.UserName = $user
$startinfo.Password = $pass
$startinfo.Arguments = $arguments
$startinfo.UseShellExecute = $False
$startinfo.RedirectStandardInput = $True
$process.StartInfo = $startinfo
$process.Start() | Out-Null
$process.WaitForExist()
$output = $process.StandardOutput.ReadToEnd()
另外我試圖運行此過程爲最小化或隱藏,但它不起作用。
任何幫助將是非常讚賞 問候 阿賈克斯
我從來沒有見過這麼明確的解釋。我非常感謝你,我會立即嘗試一下。再次非常感謝:-) – ajax
嗨,你知道如何成功傳遞參數數組我想通過這個「[Microsoft.Win32.Registry] :: SetValue('HKEY_CURRENT_USER \ Environment','$ keyVar',' $ valueVar','$ regType')「3次在參數數組中。但我得到一個異常 – ajax
雅得到它解決。謝謝 – ajax