首页 > 解决方案 > 如何从 PHP 启动 Powershell 脚本并添加参数

问题描述

我需要通过 PHP 执行带有按钮的 Powershell 脚本并且我需要添加参数并将它们返回给 php

echo Shell_Exec ('powershell -InputFormat none -ExecutionPolicy ByPass -NoProfile -Command  "& { . \"C:/Users/Alexl/Desktop/Schuljahr 19-20/Diplomartbeiten/Powershellscript/firstscript.ps1\";}" & -Temperatur 24 -Ort Leipzig ');

我在一个按钮中尝试了这个,它启动了脚本,但没有添加值 24 和莱比锡

参数([十进制]$Temperatur = 18.0,

[字符串]$Ort = "柏林")

Write-Host "Es sind $Temperatur grad C in $Ort."

它只是启动脚本并在柏林返回“ Es sind 18 grad C 所以它不会改变变量参数......

标签: phppowershellshell-exec

解决方案


推荐阅读