我想sc create从powershell脚本调用.这是代码.
function Execute-Command
{
param([string]$Command, [switch]$ShowOutput=$True)
echo $Command
if ($ShowOutput) {
Invoke-Expression $Command
} else {
$out = Invoke-Expression $Command
}
}
$cmd="sc create `"$ServiceName`" binpath=`"$TargetPath`" displayname=`"$DisplayName`" "
Execute-Command -Command:$cmd
Run Code Online (Sandbox Code Playgroud)
这给出了以下错误:
Set-Content : A positional parameter cannot be found that accepts argument 'binpath=...'.
At line:1 char:1
Run Code Online (Sandbox Code Playgroud)
问题是什么?什么是位置参数?