Using sc.exe

To communicate with the Service Control Manager, you can use a command-line tool called sc.exe. To register our executable as a service, we'll use its create command. Every service gets a behind-the-scenes short name such as testsvc. Specify the new name as the first parameter to create. The binPath parameter sets the path to the executable. Be sure that the equal sign has no spaces before it and one after it. Follow this convention with all sc.exe parameters that use an equal sign.

sc create testsvc binPath= "C:\WindowsService1.exe"

After running this command, you'll see the new service in the services management console (services.msc) amongst the other installed services. Yours will show up as testsvc. It won't be started yet for ...

Get WiX: A Developer's Guide to Windows Installer XML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.