Timer in a Windows service - not really working?

I have a Windows NT Service in C# which basically wakes up every x seconds, checks to see if any mail notifications need to be sent out, and then goes back to sleep.It looks something like this (the Timer class is from the System.Threading namespace):public partial class MyService : ServiceBase{ private Timer _timer; private int _timeIntervalBetweenRuns = 10000; public MyService() { InitializeComponent(); } protected override void OnStart(string[] args) { // when NT Service starts - create timer to wake up eve...Read more

windows services - Is ServiceAccount available in .NET Standard 2.0?

.NET Core/Standard 2.0 now lets you reference old .NET Framework libraries. You can install them via NuGet, and the code will build. This works within limits though: "The supported scenario is referencing a .NET Framework library that happens to only use types within the .NET Standard API set." -- Announcing .NET Core 2.0When using Topshelf from a .NET Core 2.0 application, I get the following exception:There seems to be a dependency on System.ServiceProcess.ServiceAccount that is not satisfied. Is this dependency available within the .NET Sta...Read more

Start / Stop a Windows Service from a non-Administrator user account

I have a WindowsService named, say, BST. And I need to give a non-Administrator user, UserA, the permissions to Start/Stop this particular service. My service runs on a variety of Windows OS, starting from Windows Server 2003 to Windows 7.How can I do this?I Googled and found some stuff about giving permissions using the command [sc sdset], but I am not exactly sure about the parameters. I do not want to set the permissions for a group, but ONLY to a particular user, UserA in this case....Read more

windows services - "Automatic" vs "Automatic (Delayed start)"

When installing Windows services there are two options for automatically starting a Windows service on Windows startup. One is Automatic, and the other is Automatic (Delayed start). What is the difference between these two in detail?For example, if you're creating the installer with wixtoolset, the ServiceConfig element has the DelayedAutoStart attribute. How will that effect what happens when services are started at boot time?WiX documentation: ServiceConfig Element...Read more

x509certificate - How do I use a certificate called from a Windows Service program with the Network Service account?

I'm using the Trans Union New Access system to run credit reports. I'm doing this on my Windows 7 64 bit development machine.I have a Web Application (web forms) project that uses the system. In one button, I have the following code: CreditReportRequestXML requestXMLSupplier = new CreditReportRequestXML(); requestXMLSupplier.RunPendingRequests();This code calls a method in another project that I coded myself. The code constructs XML that is posted to Transunion. I get perfectly good responses.I have another project that's ...Read more

SonarQube Service Starts, Runs and then Stops?

I have a Windows 2012 R2 server and I managed to install the SonarQube 5.4 server as a Windows Service. I also set up a user so the service can actually start without the infamous "It started then stopped" error a lot of people seem to get. Before installing the server as a windows service, I checked that it worked using StartSonar.bat and it did work just fine, so I was confident when I made it into a service.But when I try to access http://localhost:9000 there is nothing there, and it appears that shortly after starting the service it stops w...Read more

windows server 2012 r2 - Check if a given service name exist or not and its status with NSSM API

I am trying to build a kind of self contained system where i copy my application executables in a place and run the services as standalone applications, no installations. I am using NSSM executable to create services in windows server 2012 R2 and on one machine, there are going to be a lot of deployables. My problem is that while automating the deployment with Ansible, i am stuck at the point where i need to know if a given service name already exists and if yes, what is its state ? There don't seem to be any API in NSSM to check that. How can ...Read more

install redis as windows service

I've just installed redis on windows with MSOpenTech port. Everything is fine but the windows service. In order to run cmd, I need to create Redis command line arguments which I don't know how to achieve.How can I solve this problem?This is the instruction: Running Redis as a Service In order to better integrate with the Windows Services model, new command line arguments have been introduced to Redis. These service arguments require an elevated user context in order to connect to the service control manager. If these commands are invoked...Read more

installutil - Problem installing windows service

I am having a problem installing a Windows service. I installed and uninstalled the service numerous times (installutil..... installutil /u) without any problem but something went wrong and now when I attempt to install, I get the error message listed below. I checked the computer management console, and service CIMediator does not appear on the list of services. How do I remove the service?System.ArgumentException: Source CIMediator already exists on the local computer....Read more

How to solve "The specified service has been marked for deletion" error

I try to remove a Windows Service with sc delete <service name>, and encounter the following error: [SC] DeleteService FAILED 1072: The specified service has been marked for deletion.What I've already done:Stopped the service, obviously. The sc queryex "<service name>" gives the following result:SERVICE_NAME: Stub service TYPE : 10 WIN32_OWN_PROCESS STATE : 1 STOPPED WIN32_EXIT_CODE : 1067 (0x42b) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x0 WAI...Read more

Msmq and WCF Service

I have created a WCF service using the NetMsmq binding for which i created a private queue on my machine and executed the project. This works fine as such and my WCF service is started and accesses the message using the queue in the debugging environment. Now, I wanted to host the service using the windows service and for the same I created a new project and windows installer as well (This service runs under Local System Account). Then I tried installing this windows service using the InstallUtil command through the command prompt. When install...Read more

Log4net is not creating the log file after installation of the windows service

I m implementing a windows service with log4net logger. The thing is when I debug the service, the log is created but after installing, the log is not creating. I used app.config file and another config file to add configuration details This is my app.config file<?xml version="1.0" encoding="utf-8" ?> <configuration> <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> </startup> <appSettings><!--Log file configuration--><add key="log4net.Config" value="log4.config"/>...Read more

Hosting Workflow-Foundation in Windows Services

I am in the process to implement a Windows Service which is hosting a "Sequential Workflow" (Windows Workflow-Foundation). The sequential workflow is quite simple and, basically, is nested in a while activity which never ends.The primary purpose is to schedule jobs over a certain period of time.Since the project shares part of the infrastructure with an ASP.NET MVC application, I would like to re-use what I've built so far.I've split the windows-service project in two part: the service itself and the workflow project.The service is a "stupid" c...Read more

wix - How can I prevent a pop-up asking to shut down services before uninstalling

I have a WiX installer that runs a program that downloads the latest version of my code and installs three windows services. I have a custom action runs another program that shuts down and uninstalls the services during uninstallation, after InstallInitialize. The uninstaller also deletes all files and directories that get downloaded. However, when I RmeoveFile actions to delete the files, it prompts the user to shut down the services, since it must detect the conflict. I would like to avoid this, since my custom action does that anyway.So I ne...Read more

windows services - How do you run CMD.exe under the Local System Account?

I'm currently running Vista and I would like to manually complete the same operations as my Windows Service. Since the Windows Service is running under the Local System Account, I would like to emulate this same behavior. Basically, I would like to run CMD.EXE under the Local System Account.I found information online which suggests lauching the CMD.exe using the DOS Task Scheduler AT command, but I received a Vista warning that "due to security enhancements, this task will run at the time excepted but not interactively." Here's a sample comman...Read more