0

I created WCF service, using windows service application, i gave reference as wcf service dll to window service application, and i created exe using innosetup,for creating setup i followed this How to deploy WCF services using INNO setup? ,now how can i start the service automatically, after finishing the installation,service should start automatically.how it is possible? can i get any command line to achieve this task?

Regards, Lokesh.J

Community
  • 1
  • 1
lokesh
  • 27
  • 1
  • 11
  • I don't know what do you mean with *any command* line, but it's quite obvious from [`this post`](http://stackoverflow.com/a/15574358/960757) that the code in the `[Run]` section executes a command line with `--install` parameter, isn't it ? – TLama Mar 26 '13 at 09:31
  • yes,actually it put entry in window service,but it doesn't start the service automatically, user need to start the service manually, i don't want user to start the service manually. how can i achieve it? – lokesh Mar 26 '13 at 09:36
  • 1
    Add a `--start` parameter to the command line and make your application start the service itself when it receives it. (There are other ways, but this always seems the cleanest to me.) Don't forget that you need to stop the service on uninstall and reinstall too. – Miral Mar 26 '13 at 19:55

1 Answers1

0

you can use the following code to create a service and service will start automatically.

// create a system service with windows command “sc”
DosCmd := '/C '+'sc create "WCF" binPath= "'+ExpandConstant('{app}\WCF.exe' \
  type= share start= auto DisplayName= "WCF"'+' obj= '+UserName+' password= '+Passwd;
Exec(ExpandConstant('{cmd}'),DosCmd, '',  SW_HIDE,ewWaitUntilTerminated, ResultCode);

and then, the WCF service will start automatically.

LEo
  • 442
  • 5
  • 21
  • For more help,run "sc /?" in windows. – LEo Jul 23 '14 at 02:35
  • I'm still wondering, why do people tend to execute command line interpreter for everything. The `sc.exe` is a standalone command line tool which you can execute directly without the interpreter. And here is the same, you have shown no control over the situation when something goes wrong. – TLama Jul 23 '14 at 07:46
  • thk for your suggestion. I will continue to learn, I am a green hand.:) – LEo Jul 23 '14 at 13:16