2016-08-10 2 views
0

시작시 실행되는 PowerShell 스크립트가 있으며 몇 가지 배치 파일이 생성됩니다. 나중에 사용자가 사용할 필요가 있으므로 배치 파일을 직접 작성해야합니다.PowerShell의 externam CMD 창에서 배치 파일을 실행하십시오.

이 PowerShell 스크립트는 서버가 종료 될 때까지 이러한 CMD 창을 유지하므로이 CMD 창에서 각 배치 파일을 실행해야합니다.

각 배치 파일에 대해 새로운 CMD 창이 표시 될 수 있지만 배치 파일을 실행할 수없는 것처럼 보입니다. 내가 도대체 ​​뭘 잘못하고있는 겁니까?

### 
# Grab the WebDriver folder and the public IP of this server 
## 
$webDriverFolder = "C:\WebDriver" 
$WebDriverHubFilePath = "$webDriverFolder\Launch WebDriver Hub.bat" 
$WebDriverIENodeFilePath = "$webDriverFolder\Launch WebDriver InternetExplorer Node 1.bat" 
$publicIP = (Invoke-WebRequest ifconfig.me/ip).content 

### 
# Generate the batch file contents 
## 
$webDriverHubStr = "batch file stuff" 
$WebDriverIENodeStr = "different batch file stuff" 

### 
# Generate up to date WebDriver batch files (with the correct IP and folder path) 
## 
$webDriverHubStr | Out-File "$WebDriverHubFilePath" 
$WebDriverIENodeStr | Out-File "$WebDriverIENodeFilePath" 

### 
# Run the commands to launch WebDriver Hub and IE Node 1 
## 
Start-Process cmd.exe "$WebDriverHubFilePath" 
Start-Process cmd.exe "$WebDriverIENodeFilePath" 
+2

당신은 어떤을 검색 한 시도? http://stackoverflow.com/questions/20645326/safest-way-to-run-bat-file-from-powershell-script – lit

+0

아니요, 코딩 문제에 대한 해결책을 찾을 때 Stack Overflow를 무시하도록 Google을 수동으로 구성합니다. 모두의 시간을 낭비하십시오./풍자 –

답변

1

Start-Process -FilePath cmd.exe -ArgumentList "/c $WebDriverHubFilePath" 
Start-Process -FilePath cmd.exe -ArgumentList "/c $WebDriverIENodeFilePath" 
+0

나는 이걸 찾았지만, 내 목적으로는'/ k'와'/ c'를 반대했다. 감사. –

관련 문제