Home >Backend Development >PHP Tutorial >调用powershell不成功

调用powershell不成功

WBOY
WBOYOriginal
2016-06-23 14:24:372206browse

powershell php

PHP调用powershell指令执行不成功

    echo shell_exec('powershell echo yy'); // 会输出yy

但是如果使用file参数就不行

    echo shell_exec('powershell -file test.ps1'); // 输出空

    // test.ps1中内容为
    echo yy

------------------------------------------

各位求助~~


回复讨论(解决方案)

路径都没问题么?

路径都没问题么?

test.ps1与这个php文件在同一个目录 难道还要写上绝对路径?我try try

路径都没问题么?

powershell中加上-executionpolicy unrestricted就可以了

powershell -executionpolicy unrestricted -file test.ps1

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn