[英]Run bat file which contains powershell script using php?
I want to run bat file via php.This bat file contains power shell script.I am able to run this via cmd but not via php.我想通过 php 运行 bat 文件。这个 bat 文件包含 power shell 脚本。我可以通过 cmd 但不能通过 php 运行它。
AwsExecute.bat is, AwsExecute.bat 是,
powershell -command ./AWSExecuter.ps1
This AwsExecuter.ps1 which is inside the C:\\AWS\\Distributed-setup-3 folder.此 AwsExecuter.ps1 位于 C:\\AWS\\Distributed-setup-3 文件夹中。
In php I have tried like this,在 php 我试过这样,
Trail.php which is in http://localhost/performance folder. Trail.php 位于http://localhost/performance文件夹中。
<?php
exec('C:\AWS\Distributed-setup-3\AwsExecute.bat');
echo "Done";
?>
As well as,也,
<?php
exec('c:\WINDOWS\system32\cmd.exe /c START C:\AWS\Distributed-setup-3\AwsExecute.bat');
echo "Done";
?>
Both are not working here, I tried to another bat file which just creates a php file it works fine.两者都在这里不起作用,我尝试了另一个 bat 文件,它只是创建了一个 php 文件,它工作正常。
That is First.bat,那是First.bat,
echo off
break>"C:\Users\Vidya\Desktop\performance.php"
echo done
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.