Home » Posts tagged '#SCcreate'
Tag Archives: #SCcreate
sc command in Windows can be used to create a service. Here’s an example command to create a simple service named “MyService” that executes a batch file:
sc create MyService binPath= "C:\Path\to\batchfile.bat" start= auto
If the path is having extra lines with spaces and you want to also add double quotes ” in the path then use below example
sc create MyService binPath= "\"C:\Path\to\batchfile.bat\" \"C:\AnotherPath\to\anotherbatchfile.bat\"" start= auto
Let’s break down the command and its options:
sc create: This specifies that we want to create a new service.
MyService: This is the name you want to assign to your service. You can replace it with your preferred name.
binPath=: This option specifies the path to the executable or script that will be run as the service. In this example, it’s set to
"C:\Path\to\batchfile.bat". Replace this with the actual path to your batch file.
start= auto: This option sets the service to start automatically when the system boots up. You can change it to
demandif you want to start the service manually.
After executing the command, the service “MyService” will be created on your system using the provided batch file as the executable. You can then manage the service using commands such as
sc start MyService,
sc stop MyService, and
sc delete MyService to start, stop, or delete the service, respectively.
Please make sure to adjust the paths and options according to your specific requirements.