windows-services

Detect if code is running as a service

*爱你&永不变心* 提交于 2019-11-30 20:02:28
Is there a way for an .NET library to detect whether or not it is being run as a service? My library can be run either way. But when its run as a service, developers need to call an additional method indicating that fact or certain features won't work correctly. I want my library, which handles logging, to write a warning if it is used in a service without that method being called. Rob Parker After much searching through intellisense, the debugger, and documentation we weren't able to find anything strictly reliable. It may be possible to get the current process Id and try to find out if that

What is the difference between deleting & uninstalling in the context of a Windows Service?

心不动则不痛 提交于 2019-11-30 19:15:22
问题 Please help me understand the difference between deleting a windows service with the command "sc delete " and uninstalling a windows service with the command "installutil /u ". After exploring a little bit I realize that for using the installutil command you have to first stop the windows service while sc delete command take care of stopping the service itself. Please correct me if wrong. 回答1: A related SO question and answers (two in particular - here and here) explain the difference as

How to retain service settings through InstallShield upgrade install

北战南征 提交于 2019-11-30 18:58:07
问题 I have an InstallScript project in IS2010. It has a handful of services that get installed. Some are C++ exes and use the "InstallShield Object for NT Services". Others are Java apps installed as services with Java Service Wrapper through LaunchAppAndWait command line calls. Tomcat is also being installed as a service through a call to its service.bat. When the installer runs in upgrade mode, the services are reinstalled, and the settings (auto vs. manual startup, restart on fail, log-on

How to determine Windows.Diagnostics.Process from ServiceController

荒凉一梦 提交于 2019-11-30 18:46:58
This is my first post, so let me start by saying HELLO! I am writing a windows service to monitor the running state of a number of other windows services on the same server. I'd like to extend the application to also print some of the memory statistics of the services, but I'm having trouble working out how to map from a particular ServiceController object to its associated Diagnostics.Process object, which I think I need to determine the memory state. I found out how to map from a ServiceController to the original image name, but a number of the services I am monitoring are started from the

Need a way to check status of Windows service programmatically

試著忘記壹切 提交于 2019-11-30 18:46:29
Here is the situation: I have been called upon to work with InstallAnywhere 8, a Java-based installer IDE, of sorts, that allows starting and stopping of windows services, but has no built-in method to query their states. Fortunately, it allows you to create custom actions in Java which can be called at any time during the installation process (by way of what I consider to be a rather convoluted API). I just need something that will tell me if a specific service is started or stopped. The IDE also allows calling batch scripts, so this is an option as well, although once the script is run,

Get the computer name in a Windows service?

假装没事ソ 提交于 2019-11-30 18:18:40
In a .NET Windows service (C#), how can I get the computer name? Is this a reliable method, or should I wrap it in a try/catch? Look at the Environment class . There're lots of nice things in there, including the MachineName : string CurrentMachineName = Environment.MachineName; According to the docs, this could generate an InvalidOperationException so you'll need to be aware of that possibility. The risk probably doesn't warrant wrapping it in a try/catch, though. I think first you have to decide what you mean by "computer name". As others have said, and possibly "traditionally" on windows,

SignalR self hosted windows service, listening for messages

不问归期 提交于 2019-11-30 18:12:42
问题 I'm attempting to build a windows service that's self-hosting SignalR. I have read through tutorials such as SignalR Self-Host on ASP.Net I'm noticing that, least it seems, that they're based around broadcasting messages, and can't seem to find anything around listening. I need to listen to messages from within the service, as well as broadcast. We already have our backplane setup - it's the same one that the site uses. In a web site I can join a group, via Javascript. How do I join a group

Set-Service: Cannot stop service because it is dependent on other services

只愿长相守 提交于 2019-11-30 17:52:47
问题 When I run the following command: Set-Service -ComputerName appserver -Name MyService -Status Stopped I get an error message: Set-Service : Cannot stop service 'My Service (MyService)' because it is dependent on other services. At line:1 char:12 + Set-Service <<<< -ComputerName appserver -Name MyService -Status Stopped + CategoryInfo : InvalidOperation: (System.ServiceProcess.ServiceController:ServiceController) [Set-Service], ServiceCommandException + FullyQualifiedErrorId :

How can I replace the current Java process, like a unix-style exec?

我是研究僧i 提交于 2019-11-30 17:29:47
问题 I have a server written in Java that runs as a Windows service (thanks to Install4J). I want this service to be able to download the latest version of the JAR file it runs from, and start running the new code. The stitch is that I don't want the Windows service to fully exit. Ideally, I would accomplish this by a unix-style exec() call to stop the current version and run the new one. How can I best accomplish this? 回答1: Here is a complicated, but portable, way. Split your code into two jars.

Run JAR as a Windows service [duplicate]

大城市里の小女人 提交于 2019-11-30 17:26:14
This question already has an answer here: How to create windows service from java jar? 8 answers I have a JAR file and I would like to register and run it as a Windows service. With a well-configured JAR and already registered JVM shutdown hooks it should not be a big work to do this. I already have a JAR with external lib dir, I can start it with java -jar My.jar and stop with Ctrl+C . I also checked JSL, JSmooth, and procrun from Apache with no working solution. I would need a working solution with a good tutorial. Update: I succeeded with both procrun (at last), and the manual .net service