windows-services

Make windows service run as if it was run from a specific user

拈花ヽ惹草 提交于 2019-12-24 03:58:06
问题 I want to create a windows service to mount and dismount a True Crypt volume. (this question is not about true crypt so if you do not know what that program that is ok. True Crypt is just a program that enables you to encrypt data. When you decrypt it then trueCrypt will create a virtual drive where you can see the contents unencrypted). Here is the code I use in my console application: static void Main(string[] args) { Test(); } static void Test() { try { // location where true crypt is

Setup Project - Allow multiple installation of the same Windows Service

无人久伴 提交于 2019-12-24 03:08:22
问题 I have a question regarding to Setup Projects in .Net (c# language, Framework 4.0): I made a setup project for a Windows Service, on the installation wizard, the user must input the name of the Windows Service as it would be installed. The setup program also creates a shortcut to the Uninstall program in case the user wants to remove that Windows Service. The question is: how to let the user run the same setup program several times specifing different service name ? This behaviour could be

.net core console app as windows service- Is it possible to safely kill execution of started process without using Kill() method?

痴心易碎 提交于 2019-12-24 03:07:46
问题 I have a dotnet core 2.2 console app. I hosted it as windows service.(Service name: "MyService1") "MyService1" starts up another dotnet core WebAPI. The problem is, how do I safely kill the WebAPI process when the "MyService1" is stopped? Here is how I tried to do that but I can still see the process in the task manager. public class MyService : IHostedService, IDisposable { private Timer _timer; static Process webAPI; public Task StartAsync(CancellationToken cancellationToken) { _timer = new

Set the port number in windows service

試著忘記壹切 提交于 2019-12-24 03:04:45
问题 I am going to develop a windows service. When the service starts, there is a port with it. My question is that can we assign a specific port number to it? Example, port number is "55431". 回答1: Yes. Assuming you're using WCF as the communication layer, you would just configure the binding/protocol to listen to as part of the service configuration. In your service's OnStart() method you would register the port. You would un-register it, when the service stops. Complete Walk-Through protected

How to Call an Async Method from within ElapsedEventHandler

怎甘沉沦 提交于 2019-12-24 00:28:16
问题 I'm going to use a Windows Service to send Telegram Messages periodically (Every two minutes). My Windows Service starts fine and after 2 minutes it is stopped. I checked my code and find out it is because of async. How can I solve the problem? protected override void OnStart(string[] args) { //< I declared a System.Timers.Timer to send new Telegram messages. aTimer = new System.Timers.Timer(120000); // 2 minutes aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Enabled = true;

SqlDependency code listening to inserts/update in a table from windows service

时光怂恿深爱的人放手 提交于 2019-12-24 00:04:05
问题 my SqlDependency code is listening to inserts/update in a table from windows service and when i start the service then it works for next 2/3 days and after that it stopped working. here i am pasting my full code. public partial class PartIndexer : ServiceBase { static string connectionString = "MyConnection String;Pooling=true;Connect Timeout=20;"; SqlDependency dep; public PartIndexer() { InitializeComponent(); } #region OnStart protected override void OnStart(string[] args) { System.Data

Can developers “force” the system to prevent “Metro” apps from being suspended while background async processes are running?

吃可爱长大的小学妹 提交于 2019-12-23 23:07:08
问题 When an app is not currently "front and center" in Win8, it is suspended. Does this preclude keeping the app explicitly alive in the background, such as in an email client, using async operations to poll the mail server for new messages, and download them (and then update the Tile with count of new messages)? If this is not possible (a suspended app cannot perform background processing, or cannot force the system to allow it to stay active, albeit not visible), what would be the workaround -

System.Windows.Controls.WebBrowser, System.Windows.Threading.Dispatcher, and a windows service

て烟熏妆下的殇ゞ 提交于 2019-12-23 19:35:09
问题 I'm trying to render some html content to a bitmap in a Windows Service. I'm using System.Windows.Controls.WebBrowser to perform the render. The basic rendering setup works as a standalone process with a WPF window hosting the control, but as a service, at least I'm not getting the LoadCompleted events to fire. I know that I at least need a Dispatcher or other message pump looping for this WPF control. Perhaps I'm doing it right and there are just additional tricks/incompatibilities necessary

How to override the keys in windows services .exe.config file through VSTS release definition

吃可爱长大的小学妹 提交于 2019-12-23 17:49:32
问题 I am working on VSTS release task for deploying the Windows Services Project. Unfortunately, we are not creating any Build Definition for creating drop folder. But, my client will provide drop folder for this project, what I need is “I want to override the keys of an existing .exe.config file” at release level. For creating the Windows Services Deploy task,I followed this Windows Services Extension For example my drop folder looks like below: Many thanks for this reference article and It's a

Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)) when running through Windows Service?

不问归期 提交于 2019-12-23 17:33:41
问题 i am try to hook to outlook application from windows Service but getting an exception Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE)) here is my code. public void ItemSendEvent() { try { if (Process.GetProcessesByName(ApplicationConstants.OUTLOOK_PROCESS_NAME).Count() > 0) { // If so, use the GetActiveObject method to obtain the process and cast it to an Application object. outlookApplication = Marshal.GetActiveObject(ApplicationConstants.OUTLOOK_APPLICATION_NAME