2013-06-18 1 views
0

내 programm에서 windows powershell 스크립트를 실행해야합니다. 이를 위해 필자는 스크립트 본문 자체가 포함 된 문자열 인수를 사용하여 powershell 프로세스를 시작합니다.스크립트 본문을 powershell.exe와 param 및 다른 매개 변수로 실행하십시오.

Process.Start("powershell.exe", "my script body.."); 

그리고 작동합니다. 하지만 스크립트에 몇 가지 인수를 전달해야합니다.

Process.Start("powershell.exe", "some args my script body.."); 
  • 이 문제는 다음과 같습니다 것처럼 보일 것입니다. 나는 그것이 가능하다는 것을 안다. 나는 description을 찾았지만 그러한 예는 없다. 도움말, 제발

답변

2

당신이 뭔가를 할 수 있어야 the doc에서 :

TEST가

편집 질문을 읽고 다시 후 스크립트에 전달되는 인수입니다

process.Start("powershell.exe","-noprofile -file c:\temp\test.ps1 TEST -noexit") 

:

process.Start("powershell.exe","-noprofile -command {write-host $args[0] } -args 'test'") 
0

작동 해결책 :

Process.Start("powershell.exe", "-noexit -command &{write-host $args[0]} arg1Value arg2Value"); 
관련 문제