windows-services

Can't debug Java Windows Services with jhat, jps, jstack

I frequently showcase the jhat, jps, and jstack tool set to developers on Linux and Mac. However, a developer recently indicated that these are unusable in Windows if the Java app in question is running as a Windows Service. A Sun-filed bug says something very similar, but was closed due to inactivity. I have tested this out for mysel...

Windows Service looping - How To?

I have build a windows service using a timer which is not ideal for what i want to do. I have a methord i want to call and as soon as its finnished i want it to start again and again and again. What is the best way of doing this and can you show me an example. ...

Restart Service when Exception is thrown

I am writing a windows service that needs to be running 24/7. It is a pretty simple service that monitors a directory where files are dropped into and processes those files. I need to restart the service if an unhandled exception is thrown. Is there a way for a service to restart itself in the event of an unhandled exception? ...

How to force the removal of a windows service?

I created and installed a .NET Windows Service and now that I deleted its executable file I can't remove it from services.msc anymore with InstallUtil.exe /u executablefilename.exe How do I remove it? ...

Check for environment variable in another process?

In Windows, is there a way to check for the existence of an environment variable for another process? Just need to check existence, not necessarily get value. I need to do this from code. ...

What would be the best way to persist user-editable settings for a Windows Service?

I'm developing an application that's going to be implemented as a Windows Service and I was wondering what'd be the best way to deal with the different settings (at User and Application level). The thing is, I'm not completely familiar (yet) with all the available options, so in principle I'm favoring .NET's own System.Configuration (Con...

how can you debug this error? The <service name> service could not be started. The service did not report an error.

The service could not be started. The service did not report an error. I encounter this error whenever I install a windows service project in the command line. It's true that there's an error in my code, but how can I find that error with this kind of error message? ...

Windows Service terminated unexpectedly

Hi, I have a windows service which has a number of threads that do some work. All has been going well in testing, until once, where I saw "windows service terminated unexpectedly" in the event viewer. How do I go about trying to debug where this is happening? I have exceptions being caught under normal circumstances but not in this c...

Executing sc.exe from .NET Process unable to start and stop service.

I'm trying to restart the service from a remote machine. Here is my code. The problem is that I need to enter startinfo.filename = "sc.exe" since I'm putting "start /wait sc" this is causing an error. Here is my code, any thoughts. Also if anyone has any idea how to keep the cmd window open after this is ran so I could see the code that ...

What is the difference between a windows service and a regular application?

I have only created regular windows applications (C# mostly). What differentiates a windows service from a regular windows application? What makes them different? What can a service do that an application can't? What are the differences seen from a developers point of view? How do you create one? Is it just to create a regular applicatio...

how to set a Windows Service to be auto-restart in PowerShell?

Hello everyone, If I know a service name, and have enough permission. My question is how to set a Windows Service to be auto-restart in PowerShell? I am using PowerShell 1.0, OS is Windows Server 2003. thanks in advance, George ...

Error stopping a Windows Service

Hello everyone, I am using PowerShell 1.0 on Windows Server 2003 x64. When executing the following statement, there is error below. Not every time this error occurs, and if this error occurs and I execute this command again, there is no error again! It is so weird. Any ideas what is wrong? Stop-Service "SQLServerAgent" -Force -ErrorAct...

Email on Error Implementation

Hi all, I've been working on a .Net Windows Service and i was wondering how to implement sending out an email on an error from within the service. I entertained myself with the idea of sending the email from within a catch block, but then i remembered that there could be an error within sending an email as well and an unhandled exceptio...

Should I host my WCF service in IIS?

So I'm designing a WCF service. I'm unexperienced with WCF, and I'm trying to decide whether it should be hosted in IIS, or a custom Windows service.. Or some other option? Things to consider: It needs to load data from a database on startup. It needs to maintain this data across requests, not load it each time. It needs to process mu...

impersonation for windows service using config file

Currently to run windowsservice as a fixed user we set the logon properties on the windows service (where we specify the username and password to run as). but iam willing to have this feature of running the windows service as a fixed user as impersonation in web application mentioned in the config file. kindly throw your thoughts on t...

Can GetSetting() be called in a Windows Service?

I have written a window service. and I am able to successfully install/run the service. Now I have added a timer to the service and I want to be able to adjust the interval via the registry. But I can't figure out why GetSetting("MyAppName", "MySection", "IntervalSetting") will NOT return the value in the registry! Am I missing som...

Send windows message to a Windows Service

Is there any tool to send (mimic) a windows message like 'WM_ENDSESSION' to a windows service? OR How can I send a windows message to a process using C#? (I know only C#) EDIT: Purpose: Basically I have to debug a windows service for fixing a bug that occurs only on system shut down. ...

Is it possible to programmatically set the user account for a windows service?

I have created a windows service that has the Account set to user. Which means that when I install the service I need to pass a user name and password. Is there a way to set these maybe in the ProjectInstaller class maybe in the BeforeInstall event? if so HOW? ...

An appropriate way to Demo a windows service to a client

So i've been asked to demo a windows service to customers, but i'm clueless on how to go about doing so. I've demo'd a web/windows based ap before by just bringing up the application and going through each screen, but with a windows service it isn't the same. Can anyone point me in the right direction? All the service does is downloads ...

How long can/should an NHibernate session be kept open?

Hi, I've created a windows service which is listening to a MSMQ. For each message I receive, some DB transactions need to be made. Later it might be possible that there will be 1 message every second. Currently the Nhib session is kept open until the service is stopped manually. Is it a good practice or should I close the session after ...