Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 895
Kanishka Munshi Avatar asked Jun 27 '18 11:06

Kanishka Munshi


People also ask

What is Binpath?

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.

What is SC in PowerShell?

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.

What is SC create?

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.

What is SC exe?

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.


3 Answers

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.

like image 106
Jaypatrick M Avatar answered Oct 20 '22 20:10

Jaypatrick M


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.

like image 22
flerb Avatar answered Oct 20 '22 20:10

flerb


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

like image 2
Jay Avatar answered Oct 20 '22 20:10

Jay