windows-services

Keep C# application running

泄露秘密 提交于 2019-12-11 17:38:49
问题 I'm building a Windows Service that uses FileSystemWatcher, and runs in the background. I don't want to keep on uninstalling and installing the service every time I want to debug, so would like to do most of my development in a normal program before moving it into a service. But I'm quite new to this, and when I run it, it just runs through the block and exits. What would be a good way to keep the program running? 回答1: http://einaregilsson.com/run-windows-service-as-a-console-program/ I've

Print Pdf from windows service and keep working after logoff

对着背影说爱祢 提交于 2019-12-11 17:37:16
问题 I am creating a windows service that will print pdf in time interval. I have done some research on this and found a class public class ProcessStarter : IDisposable { #region Import Section private static uint STANDARD_RIGHTS_REQUIRED = 0x000F0000; private static uint STANDARD_RIGHTS_READ = 0x00020000; private static uint TOKEN_ASSIGN_PRIMARY = 0x0001; private static uint TOKEN_DUPLICATE = 0x0002; private static uint TOKEN_IMPERSONATE = 0x0004; private static uint TOKEN_QUERY = 0x0008; private

Why do forms fail in Windows Services

百般思念 提交于 2019-12-11 17:14:16
问题 I understand that Window's Services have no desktop, and can't access any of the user's desktops directly (indeed, they can run when there is no desktop loaded). Why is it though that launching a form in a Window's Service causes an error? 回答1: There's a setting you must enable in order to allow your Windows Service to access certain folders directly (like desktop) or show forms (including MessageBox pop-ups): "Allow service to interact with desktop" To see this, right click on My Computer =>

Timers under window service stop working after couple of days

只谈情不闲聊 提交于 2019-12-11 17:12:09
问题 Did anyone notice or is it happened to him that EDIT: a system.Timers.Timer under windows service stop invoking after couple of days when the service is running ? is there some protocol that need to be kept in order to check that the timers are running. 来源: https://stackoverflow.com/questions/6166339/timers-under-window-service-stop-working-after-couple-of-days

Startup Code for Loading COM Object for WCF Service

隐身守侯 提交于 2019-12-11 17:01:48
问题 I am currently have a WCF service that uses a COM DLL for its service. The COM object is only loaded once and saved via a singleton. The problem is the first run takes about 1 minute to load the COM Object. The WCF service is hosted via a Windows Service. I am wondering how can I load the COM Object singleton via the startup of the Windows Service. protected override void OnStart(string[] args) { if (host != null) { host.Close(); } Type serviceType = typeof(MyService); host = new ServiceHost

Windows Service notifying user with WPF outlook style control not becoming visible

[亡魂溺海] 提交于 2019-12-11 16:38:24
问题 Update: We are still using XP at work and I got my solution working, but now knowing that Vista and beyond have the isolated session I am going to implement a WCF IPC... I have a windows service that needs to notify the user of an event of some type occurring. I decided that something similar to email notification messages would make sense. It also makes sense to do such a simple UI using WPF. This would allow me to learn some basics. I run a thread: Thread thread = new Thread(new ThreadStart

How to create process as user with arguments

二次信任 提交于 2019-12-11 16:29:08
问题 Tried to create a process as a user with portablechrome.exe but I could not handle it with arguments. How can I open an HTML file with arguments? Such as portablechrome.exe sample.html --kiosk I'm using system service like this: string url = @System.AppDomain.CurrentDomain.BaseDirectory + "updater.html "; string kioskMode = url + " --kiosk --incognito --disable-pinch --overscroll-history-navigation=0 "; StartProcessAsCurrentUser("C:\\Chrome\\PortableChrome.exe", kioskMode); And my wrapper for

Windows Service installation - current directory

前提是你 提交于 2019-12-11 16:17:24
问题 this question is related to my previous one . I've written a service in C# and I need to make it's name dynamic and load the name from configuration file. The problem is that current directory while the service installer is invoked is the net framework 4 directory instead of the one that my assembly sits in. Using the line (which helps with the same problem, but while the service is already running) System.IO.Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory); sets

Windows Service fails to start when the service is already running using windows batch script

不想你离开。 提交于 2019-12-11 16:05:30
问题 I am writing a windows batch script that will Install a service. If its already running, then I am stopping and deleting the service and then installing the service again. I am facing a peculiar behavior. When the service is already running, and when I am running the below batch file, the service gets installed again, but it fails to start. When I reboot the system, and start the service, it gets started. How to solve this start service issue without rebooting computer. I also added taskkill

Windows service - Login failed for user 'NT AUTHORITY\SYSTEM'

不问归期 提交于 2019-12-11 14:56:44
问题 I've created simple console log app which behaves a windows service. I'm wondering why am I getting an error Login failed for user 'NT AUTHORITY\SYSTEM' if I change my connection string in a way to use some another user which I previously created on SQL Server. Example of connection string: <value>Data Source=DESKTOP-Z67;Initial Catalog=MyDb;Integrated Security=false;User ID=service;Password=test1234</value> Event if I specified this connection string, I'm getting error Login failed for user