windows-services

Console.WriteLine() inside a Windows Service?

流过昼夜 提交于 2019-11-29 02:51:11
I am currently using TopShelf with a Console Application to create a Windows Service. When I run the code as a console application I use a few Console.WriteLine() to output results. Once the code does what it is supposed to do I install the console application as a Windows Service. Are there any downsides with leaving the Console.WriteLine() code even though a Windows Service can not write to the console? Are there any risks of having unstable code if I leave the Console.WriteLine() in there? dtech The output will simply be discarded . In a Windows Service there is no Console so Console.Write*

How to restart service using command prompt?

大城市里の小女人 提交于 2019-11-29 02:30:59
问题 I want to restart Windows service using command prompt in [Icons] section using Inno Setup. Please help me to solve the problem. 回答1: You can use sc start [service] to start a service and sc stop [service] to stop it. With some services net start [service] is doing the same. But if you want to use it in the same batch, be aware that sc stop won't wait for the service to be stopped. In this case you have to use net stop [service] followed by net start [service] . This will be executed

Basic design pattern for using TPL inside windows service for C#

放肆的年华 提交于 2019-11-29 02:17:18
I am trying to build up windows service which need some kind of parallelism for pooling files from different ftp sources. For starting multiple ftp downloads I am looking in TPL library to easily do foreach loops and making parallelism totally easy. But when I search how to start or stop my service(s), best shot I fund is to make new threads inside OnStart() method, as it is described here https://stackoverflow.com/a/4865893/69433 Reading about TPL there is always note that TPL is more advanced than manual threading and manual stop threading. I did not find any sample post which describes how

Programmatically limit CPU Usage of a Thread running inside a Service

廉价感情. 提交于 2019-11-29 02:08:58
I'm using VB9 (VS2008). I've created a Windows Service that indexes some folders regularly. Is there a way I can put an upper limit on the CPU usage depending upon the current system state, i.e., if the system is idle, the thread can use the CPU as much as it needs, but if there are other programs/processes running then it should use the CPU in way that does not make the system slow. ShuggyCoUk You can reduce the priority of the thread, in .Net via Thread.Priority Setting it to BelowNormal will mean that other threads will be scheduled in front of it. This can lead to the thread being starved,

How to find windows service exe path

谁说胖子不能爱 提交于 2019-11-29 01:24:40
问题 I have a windows service and I need to create directory to store some info. The directory path must be relative to the windows service exe file. How can get this exe file path ? 回答1: You can use AppDomain.CurrentDomain.BaseDirectory 回答2: Tip: If you want to find startup path of installed windows service, look here from registry . HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\ + ServiceName There are keys about windows service 回答3: To get path for service you can use Management object.

Best Method to run a Java Application as a *nix Daemon or Windows Service?

半城伤御伤魂 提交于 2019-11-29 01:14:57
I am looking for the best method to run a Java Application as a *NIX daemon or a Windows Service. I've looked in to the Java Service Wrapper , the Apache Commons project 'jsvc' , and the Apache Commons project 'procrun' . So far, the Java Service Wrapper looks like it's the best option... but, I'm wondering if there are any other "Open Source friendly" licensed products out there. I've had great success with Java Service Wrapper myself. I haven't looked at the others, but the major strengths of ServiceWrapper are: Great x-platform support - I've used it on Windows and Linux, and found it easy

Why won't my windows service write to my log file?

℡╲_俬逩灬. 提交于 2019-11-29 01:09:20
I have a windows service and use nlog for logging. Everything works fine when I run from the visual studio ide. The log file updates with no issues. When I install the service, the service runs fine but the log file never updates. I am running under LOCAL SERVICE if that helps. Yes, I have created the logs directory under my application folder. <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > <targets> <target name="file" xsi:type="File" fileName="${basedir}/logs/${shortdate}_info.txt"

Update a dll without stopping the service

不羁岁月 提交于 2019-11-29 00:52:14
问题 I would like to update a dll for a server process without stopping the service. How do I do that? A bit like how asp.net automatically picks up new dlls placed in the bin folder. 回答1: Asp.Net uses a technique called shadow copy If you copy an updated dll into an application’s bin subdirectory, the ASP.NET runtime recognizes there is new code to execute. Since ASP.NET cannot swap the dll into the existing AppDomain , it starts a new AppDomain. The old application domain is “drain stopped”,

Calling System.exit() in Servlet's destroy() method

痴心易碎 提交于 2019-11-29 00:21:32
This is a follow up to my earlier question . Tomcat 5.0.28 had a bug where the Servlet's destroy() method was not being invoked by the container on a shutdown. This is fixed in Tomcat 5.0.30, but if the Servlet's destroy() method had a System.exit(), it would result in the Tomcat windows service throwing the Error 1053 and refusing to shutdown gracefully (see above link for more details on this error) Anybody has any idea on whether: Calling System.exit() inside a Servlet's destroy() method to forcefully kill any non-daemon threads is a good idea? Why does Tomcat 5.0.30 and (later versions

Executable started by a windows service using the local system account cannot access network shares

你说的曾经没有我的故事 提交于 2019-11-29 00:09:38
问题 I have an executable that is started by a windows service, this program will be run on a customers machine and will need to connect to a remote share to perform a particular task. This share is specified by the customer via a UI, so we do not know this in advance meaning it can't be "hard-coded", or the share mapped in advance. Previously we required the customer to log on to their machine and run the executable on log-on , but we have always wanted to allow our program to run within a