Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Powershell Inkove表达式_Powershell - Fatal编程技术网

Powershell Inkove表达式

Powershell Inkove表达式,powershell,Powershell,昨天我读到了关于调用表达式的文章 从…起 它工作得很好,但是如何获得结果,以及如何为.bat file添加参数?调用表达式是调用表达式,而“.bat”不是表达式 因此,如果您想调用.Bat文件,只需c:\batfile.Bat即可 或者,如果您想在调用表达式上进行探索,请将批处理文件中的命令复制到一个变量中,以查看正在执行的代码 有一个类似的例子,我不得不做一些类似的事情,我把它当作一个例子 $prog="cmd.exe" $TARGETDIR = 'd:\temp' $x='C:\Users

昨天我读到了关于调用表达式的文章 从…起


它工作得很好,但是如何获得结果,以及如何为.bat file添加
参数?

调用表达式是调用表达式,而“.bat”不是表达式

因此,如果您想调用.Bat文件,只需
c:\batfile.Bat
即可

或者,如果您想在调用表达式上进行探索,请将批处理文件中的命令复制到一个变量中,以查看正在执行的代码

有一个类似的例子,我不得不做一些类似的事情,我把它当作一个例子

$prog="cmd.exe"
$TARGETDIR = 'd:\temp'
$x='C:\Users\v-chetak\Desktop\1.bat'
$params=@("/C";"$x";" >d:\temp\result17.txt")
Start-Process -Verb runas $prog +$params 

$params
将保存您想要传递的所有参数。

如何获取bat文件日志并将其存储到powershell>d:\temp\result17.txt中的变量这就做到了,在这里,由my 1.bat创建的日志被推送到>d:\temp\result17.txt文件中,您可以按照您想要的方式调整我的代码,如果不想在管理模式下运行批处理文件,可以将Start Process-Verb runas$prog+$params更改为Start Process$prog+$params
$prog="cmd.exe"
$TARGETDIR = 'd:\temp'
$x='C:\Users\v-chetak\Desktop\1.bat'
$params=@("/C";"$x";" >d:\temp\result17.txt")
Start-Process -Verb runas $prog +$params