【发布时间】:2015-04-08 14:45:21
【问题描述】:
我有以下问题:
我有一个 xampp 服务器正在运行,我希望它执行一个 powershell。一个 php 触发一个 .bat 文件,其中包含以下代码:
@echo
cd C:\OpenBR\bin
start /WAIT br -algorithm FaceRecognition -compare C:\xampp\htdocs\upload C:\xampp\htdocs\DP C:\xampp\htdocs\results\result.csv
start /WAIT C:\xampp\htdocs\CSVconvert\sortieren.ps1
start /WAIT C:\xampp\htdocs\CSVconvert\Removedouble.ps1
start /WAIT C:\xampp\htdocs\CSVconvert\remove_path.ps1
start /WAIT C:\xampp\htdocs\CSVconvert\remove_foo.ps1
start C:\xampp\htdocs\CSVconvert\remove_quoatation.ps1
第一部分工作正常,直到我想执行 powershell“sortieren.ps1”。当我手动运行批处理时,它会执行并完成工作,当通过 php 触发时,它不会。 我在 x86 和 x64 shell 中都设置了“Set-ExecutionPolicy Unrestricted”。 我只是感到困惑,因为正常的命令行可以工作,而 powershell 不能,即使在将其设置为无限制之后也是如此。
我看过 executing a Powershell script from php 和 PowerShell on Windows 7: Set-ExecutionPolicy for regular users 但无法解决问题。 我错过了什么?
【问题讨论】:
-
Start 最喜欢打开 ps1 文件,就好像您双击它而不是运行脚本一样,您可以尝试将 Start 行更改为
Start /Wait C:\windows\system32\WindowsPowerShell\v1.0\Powershell.exe -file C:\xampp\htdocs\CSVconvert\sortieren.ps1或Start /Wait Powershell -file C:\xampp\htdocs\CSVconvert\sortieren.ps1
标签: php windows powershell batch-file