Home » Operating System
Category Archives: Operating System
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.
Go to the location of executable (or shortcut) and pressing shift key, right click on the executable (or shortcut), Choose run as different user, you can give a local or an Active Directory user, and follow the normal process of launching the program. It may ask for elevated access, in case you are running any programs that require elevated access, in that case contact your system administrator.