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?
binpath is a mandatory parameter that specifies the path to the service-wrapper-7.4.exe file. Note that a space must be used between the binpath parameter and its argument. You should also use double quotes around the argument.
PowerShell. Like every other external command SC can be run under PowerShell instead of CMD, however there is one extra complication for SC and that is the standard PowerShell alias SC which redirects to the Set-Content cmdlet.
SC CREATE allows full-time employees in SC public and charter schools to receive cost-free course work to complete add-on, alternative, or initial licensure in special education and various related services personnel areas.
Microsoft's command-line "Service Configuration Tool" program, named "sc.exe", is in "C:\Windows\System32". It allows administrative users to establish a program as a Windows service in the Service Control Manager (SCM) database and the Registry, either locally or remotely.
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.
I ran into this with Powershell as well.
To expand on the answer:
"sc" is an alias in Powershell for "Set-Content" which is confirmed in your output and by the Powershell "Get-Alias" command. That's why sc fails but sc.exe is successful, and why sc works in cmd and fails in powershell.
I was trying with powershell for a while but it didn't work. I thought maybe try it on Command Prompt (as an admin).
[SC] CreateService SUCCESS
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With