php - 如何从 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 所以它不会改变变量参数......
解决方案
推荐阅读
- curl - 在 php 登录后使用 curl
- python - 如何在python中使用sed命令将标题添加到文件中
- spring - 引起:java.lang.IllegalArgumentException:模式不能为空或为空
- google-chrome - 使用扩展更新 chrome 设置
- ios - 使用 swift 而不是 Oc 进行 KVO 时如何正确创建上下文
- sql - 查询在没有主键的两个表中查找不匹配的记录
- reactjs - 根据 React 中的 API 数据渲染材质 UI 选项卡将不起作用
- python - 为 National Instrument DAQ 卡“cDAQ-9171”设置触发器时出错
- vue.js - 将图像vue传递给控制器laravel?
- opencv-python - 我想使用opencv为制表符间隔表构建表结构