0

Until now I had a windows application that functions as a server, this server is connected to a SQL server and communicating with clients application via TCP/IP.

Each windows server can run a few of my server application. Each server application connects to a different database and use different TCP port.

The IT requested that the server will be replaced to work as a service, because one major issue they have is that when restarting the server, it's not auto login a user that can start the server application and that stuck all the clients connected to the server. The IT a las mention they cannot create a autologgin registry for security reasons.

I tried to look on the internet and saw those answers:

How can I run an EXE program from a Windows Service using C#?

Which process in windows is user specific?

How to run console application from Windows Service?

How can a Windows Service start a process when a Timer event is raised?

Can a windows service communication to SQL server and open ports without any login to the windows (after restart)?

If I do change the server application to a service. I can run only one service. So I won't have a few services per windows? and I also can't run my server application from this service because of the login issue?

Community
  • 1
  • 1
Izikon
  • 902
  • 11
  • 23

1 Answers1

1

For authentication:

If your SQL server is configured to work with Windows Authentication, then you will have a problem. The problem is not insurmountable, you are going to have to look into the concept of impersonation, but it is a bit of work. However, if the SQL Server works with username + password authentication, then you are good to go.

For multiple instances:

Ideally, you would have used nothing static anywhere in your application, so your application would be able to internally create several instances of its main application object. But let me guess, you have used static. So, what you can do in this case is this: instead of modifying your application to make it a service, write a separate service executable which launches several copies of your application, each as a separate process.

Mike Nakis
  • 56,297
  • 11
  • 110
  • 142
  • I also forget to mention that i write logs to the file system. I won't have problem writing a log files to reading registry entries? – Izikon Feb 12 '15 at 10:17
  • With registry entries you should have no problem whatsoever. With log files there is a slight chance that you ***might*** have a problem if the permissions are not right, but you can easily fix it by setting the permissions right. – Mike Nakis Feb 12 '15 at 10:22
  • 1
    If your SQL server only uses Windows Authentication, you can just set your service to logon as a particular user. – sgmoore Feb 12 '15 at 11:40
  • Oh, right. I forgot about that. This will probably make a whole bunch of things easier for the OP. – Mike Nakis Feb 12 '15 at 11:42
  • It is also possible to install multiple services (with different names) that all run the same executable. – Harry Johnston Feb 12 '15 at 19:44
  • I still have a problem running the service without login. I'm using NetworkService as the user. do i need special policies for it? – Izikon May 20 '15 at 08:20
  • I am not sure. Perhaps it is time to open a new question for this issue, explaining precisely what you are doing, and precisely what error message you are receiving. – Mike Nakis May 20 '15 at 08:46