Search code examples
windowsservice

SC create binpath error


I am trying to run the following command in the PowerShell

sc create StrongSwan binpath= "C:\Users\Kanishk\Desktop\Strong\Strong\stronswan\strongswan-5.6.3\src\charon-svc\charon-svc.exe"

I have checked the path to the .exe is correct and I can cd to it also. For reference I am following this: https://wiki.strongswan.org/projects/strongswan/wiki/Charon-svc

I am receiving the following error:

Set-Content : A positional parameter cannot be found that accepts argument 'binpath='.
At line:1 char:1
+ sc create NewService binpath= C:\Users\Kanishk\Desktop\Strong\Strong\ ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidArgument: (:) [Set-Content], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetContentCommand

So my problem is the same command is working on cmd but not on PowerShell. Any reasons why?


Solution

  • I ran into this also. It looks like the error happens at line:1 char:1. So I assumed it doesn't understand what "sc" is. So I changed sc create .. to sc.exe create .. and it worked for my service.