I was getting this error because I misread the accepted answer from here: Create Windows service from executable.
sc.exe create binPath= ""
For , I was using the path of the executable's folder, e.g. C:\Folder.
It needs to be the path of the executable, e.g. C:\Folder\Executable.exe.