make a service with sc.exe

Posted on 2007-10-18
Last Modified: 2008-02-12
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
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.

Question by:Marketing_Insists
    LVL 9

    Expert Comment

    it all depends on how your again.exe is coded...
    LVL 4

    Expert Comment


    I recomend this way (easyest)
    but if you want I have instructions for register a exe under a service. A little easy job also.

    LVL 30

    Expert Comment

    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:

    Creates a service (adds it to the registry).

    If you can get your hands on Visual Studio for .NET Version 1+ creating a service is a no brainer.
    LVL 82

    Accepted Solution

    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
    LVL 10

    Expert Comment

    Also with the
    type= interactive declaration you still need the scope ie.

    type= interactive type= own, would actually work


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Suggested Solutions

    TOMORROW TOMORROW.BAT is inspired by a question I get asked over and over again; that is, "How can I use batch file commands to obtain tomorrow's date?" The crux of this batch file revolves around the XCOPY command - a technique I discovered w…
    Learn about cloud computing and its benefits for small business owners.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now