Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restarting a service - impersonate user?

Status
Not open for further replies.

theomen

Programmer
Jun 2, 2004
158
GB
I wrote a windows service about a year ago which polls a folder every so often for files (excel spreadsheets), and any files it finds it imports into an SQL Server database.

Its been working fine on my laptop for about a year, apart from one thing. When a file fails to import (due to a column being missing for example), the service stops polling the folder. I can't figure out why this is, the timer within the service is still enabled and started, and the service is still started, but it just stops doing anything. So to get around this, I would have to use a web interface I'd written to change the polling interval to restart the service (changing the polling interval had to restart the service so that it could re-initialise and get all settings such as the polling folder and the interval itself). This has been working fine on my laptop, but as soon as I copied it to the server last week, it stopped working, due to permissions. The web page that restarted the service used the impersonation functionality of vb.net, but this doesn't work on the server.

So, inside the service itself, I told it to restart (well, just start actually) itself when a file failed to import. Again, this works fine on my laptop, on the server it fails. I can't see it being down to permissions because surely its starting itself under the account that it starts under in the first place?

Can anyone give me any advice on what I can do about this? I do have a small control panel that I wrote that I have running on my laptop and which tells me whether the service itself and any dependent services (ie. sql server) are running, and allows me to start and stop the service. However, I cannot get this to connect to the server.

Any help would be much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top