标签: sc.exe

我如何从powershell脚本调用sc创建

我想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)

问题是什么?什么是位置参数?

powershell alias sc.exe

15
推荐指数
1
解决办法
1万
查看次数

标签 统计

alias ×1

powershell ×1

sc.exe ×1