• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 39446
  • Last Modified:

make a service with sc.exe

Can someone show me WORKING SAMPLE SYNTAX to turn a exe into a service with the sc.exe utility?

I turned a batch file into a exe with a bat2exec utility, but no dice on getting it to run as a service.

::simple bat contents
:again
ping 127.0.0.1
goto again



:: trying to create it so the DOS window is always showing:
C:\>sc create newservice binpath= c:\windows\again.exe type= interact start= auto obj= %computername%\user password= abc-123
[SC] CreateService FAILED 87:

--------------
:: trying again using MS's own sample syntax...
c:\>sc create newservice2 binpath= c:\windows\again.exe
[SC] CreateService2 SUCCESS

c:\>net start newservice2
System error 5 has occurred.

Access is denied.


--------------

::fine, I'll be more explicit:
c:\>sc create newservice3 binpath= c:\windows\again.exe type= share start= auto obj= user password= abc-123
[SC] CreateService3 SUCCESS

c:\>net start newservice3
System error 1069 has occurred.

The service did not start due to a logon failure.

--------------

I give up.




0
Marketing_Insists
Asked:
Marketing_Insists
1 Solution
 
ghostdog74Commented:
it all depends on how your again.exe is coded...
0
 
jordibartrinaCommented:
Hello,

I recomend this way (easyest) http://www.softplatz.com/Soft/Utilities/Other/Exe-To-Service.html
but if you want I have instructions for register a exe under a service. A little easy job also.

HTH
0
 
SteveGTRCommented:
I think you are confused about the capabilities of sc.exe. The create option will add a service to the registry. It doesn't take a non-service structured exe and turn it into a service.

This page isn't real clear on this. Your one clue is:

Create
Creates a service (adds it to the registry).

http://support.microsoft.com/kb/251192

If you can get your hands on Visual Studio for .NET Version 1+ creating a service is a no brainer.
0
 
oBdACommented:
You can use SrvAny.exe and InstSrv.exe from the W2k3 Resource Kit Tools to let a batch file run as a service; install the Resource Kit Tools and check the help for details:
Windows Server 2003 Resource Kit Tools
http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en
0
 
Chris GralikeSpecialistCommented:
Also with the
type= interactive declaration you still need the scope ie.

type= interactive type= own, would actually work

Regards,
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now