windows-services

Play wave file from a Windows Service (C#)

匆匆过客 提交于 2019-11-26 16:58:59
问题 I need to play a wav file from a C# application running as a Windows Service. I have tried both System.Media.SoundPlayer and a P/Invoke call to WinMM.dll (which is probably what SoundPlayer is doing). [DllImport("WinMM.dll")] private static extern bool PlaySound(string fname, int Mod, int flag); If I run my code as a console application, the sounds play. When I run it from a service, no luck, and I guess I'm not surprised. So is there a way to play a sound from a windows service? Would

C#: GUI to display realtime messages from Windows Service

送分小仙女□ 提交于 2019-11-26 16:37:53
问题 I've written a C# windows service which can write messages to a custom EventLog or to any number of files. These messages are all marked with some priority (so, for example, only ERRORs and WARNINGs get stored in the EventLog, but if desired a lot more can be stored to a file). What I'd like to do now is create a GUI that can listen for these messages and display them in real-time. Allowing a user to watch the current messages (at whatever their desired priority level), without the need to

Hosting WCF service inside a Windows Forms application

筅森魡賤 提交于 2019-11-26 16:22:10
问题 I need to host a WCF service inside a Windows Forms application and call the WCF service from a Windows service that will send data to the WCF service which will show it in the Windows Forms application (desktop application). How can I implement this? I need code that is working correctly and tried before. 回答1: This code should be enough to get you started: Form1.cs namespace TestWinform { public partial class Form1 : Form { private ServiceHost Host; public Form1() { InitializeComponent(); }

How to let Timer skip tick if the previous thread is still busy

≯℡__Kan透↙ 提交于 2019-11-26 16:16:47
问题 I created a windows service, that is supposed to check a certain table in the db for new rows every 60 seconds. For every new row that was added, I need to do some heavy processing on the server that could sometimes take more than 60 seconds. I created a Timer object in my service, that ticks every 60 seconds and invokes the wanted method. Since I don't want this timer to tick while processing the new lines found, I wrapped the method in a lock { } block, so this won't be accessible by

.NET Windows Service needs to use STAThread

别来无恙 提交于 2019-11-26 16:04:54
问题 I have created a Windows Service that will be calling out to some COM components, so I tagged [STAThread] to the Main function. However, when the timer fires, it reports MTA and the COM calls fail. How can I fix this? using System; using System.Diagnostics; using System.ServiceProcess; using System.Threading; using System.Timers; namespace MyMonitorService { public class MyMonitor : ServiceBase { #region Members private System.Timers.Timer timer = new System.Timers.Timer(); #endregion #region

What's the best way to watchdog a desktop application?

自古美人都是妖i 提交于 2019-11-26 15:54:50
问题 I need some way to monitor a desktop application and restart it if it dies. Initially I assumed the best way would be to monitor/restart the process from a Windows service, until I found out that since Vista Windows services should not interact with the desktop I've seen several questions dealing with this issue, but every answer I've seen involved some kind of hack that is discouraged by Microsoft and will likely stop working in future OS updates. So, a Windows service is probably not an

Windows Service to run constantly

半世苍凉 提交于 2019-11-26 15:41:53
Ive created a windows Service called ProxyMonitor and im currently at the stage where the service is installs and uninstall's the way I want it. So I execute the application like so: C:\\Windows\\Vendor\\ProxyMonitor.exe /install Pretty self explanatory, and then I got to services.msc and and start the service, but when I do this I get the following message: The Proxy Monitor Service on Local Computer started and then stopped. Some services stop automatically if there is no work to do, For example, The performance Logs and Alerts Services My code looks like so: public static Main(string[] Args

When creating a service with sc.exe how to pass in context parameters?

孤街浪徒 提交于 2019-11-26 15:41:15
When creating Windows service using: sc create ServiceName binPath= "the path" how can arguments be passed to the Installer class's Context.Parameters collection? My reading of the sc.exe documentation is that such arguments could only be passed on the end of binPath , but I have not found an example or been able to successfully do this. Mhmd sc create <servicename> binpath= "<pathtobinaryexecutable>" [option1] [option2] [optionN] The trick is to leave a space after the = in your create statement, and also to use " " for anything containing special characters or spaces. It is advisable to

How to install node.js as windows service?

醉酒当歌 提交于 2019-11-26 15:38:39
I have downloaded node.js executable. How can I run that executable as windows service? I cannot use standard node.js installer, since I need to run multiple version of node.js concurrently. Corey Late to the party, but node-windows will do the trick too. It also has system logging built in. There is an API to create scripts from code, i.e. var Service = require('node-windows').Service; // Create a new service object var svc = new Service({ name:'Hello World', description: 'The nodejs.org example web server.', script: 'C:\\path\\to\\helloworld.js' }); // Listen for the "install" event, which

Inno Setup for Windows service?

≡放荡痞女 提交于 2019-11-26 15:36:10
I have a .Net Windows service. I want to create an installer to install that windows service. Basically, it has to do the following: Pack installutil.exe (Is it required?) Run installutil.exe MyService.exe Start MyService Also, I want to provide an uninstaller which runs the following command: installutil.exe /u MyService.exe How to do these using Inno Setup? lubos hasko You don't need installutil.exe and probably you don't even have rights to redistribute it. Here is the way I'm doing it in my application: using System; using System.Collections.Generic; using System.Configuration.Install;