windows-services

Starting GUI application from Windows Service - Approaches

橙三吉。 提交于 2021-01-28 05:34:02
问题 Note: Despite appearing as yet another question of the same matter, it's not, but choosing the right title seems hard so more appropriate title change is welcome. I'm trying to solve an issue of starting up GUI application (Windows Forms, .NET) from a service application on Windows 7 Embedded (POS ready), and have come across several solutions, but none of them worked, with one exception I discovered along the way: Using a batch file as a helper file. Background: There are several posts like

C# - Windows Service Get the Current logged user Desktop directory path

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 00:50:30
问题 I have a problem getting the Current windows logged user desktop folder when running windows service application under "Local System". when I try to use: Environment.GetFolderPath(Environment.SpecialFolder.Desktop); i get an empty string (I guess because i'm running the service under "Local System"). this is my OnStart function: protected override void OnStart(string[] args) { System.Diagnostics.Debugger.Launch(); //Get the current user desktop path; string path = Environment.GetFolderPath

C#, Calling async method inside OnStart of Windows service

主宰稳场 提交于 2021-01-27 21:18:45
问题 I am developing a windows service that is able to receive socket connection, so in the OnStart method: protected override void OnStart(string[] args) { start(); } The start function looks like this: public async void Start() { //initialization things ... ... TcpListener listener = new TcpListener(IPAddress.Any, port); listener.Start(); while(true) { TcpClient client = await listener.AcceptTcpClientAsync().ConfigureAwait(false); ... } ... } The problem is that no connection is accepted, while

Ways to leverage single code base between Windows Service and Azure WebJob

天大地大妈咪最大 提交于 2021-01-27 20:11:48
问题 I'm working on a timed recurring process that in some cases will be deployed OnPrem and in other cases deployed in the cloud (Azure). I'm researching a Windows Service and an Azure WebJob. Given that I only need the recurring process to be the timed piece, I'm thinking about having the bulk of the logic in a library with just the entry points being different between the Windows Service for the local deployment or a WebJob when deploying to Azure. Each csproj (service and WebJob) would handle

How do non-window program monitor system clipboard?

十年热恋 提交于 2021-01-27 16:02:09
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to

How do non-window program monitor system clipboard?

我的未来我决定 提交于 2021-01-27 15:56:49
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to

How do non-window program monitor system clipboard?

99封情书 提交于 2021-01-27 15:53:14
问题 I want to write a program to monitor windows clipboard using C#. I found some post about this topic. According thread How to monitor clipboard content changes in C#? and Finding the handle to a WPF window, I write a demo using WPF. In all samples code I found, all of them are WinForm or WPF apps, and win32 api they interop with need window handle as parameters. Such as api function SetClipboardViewer(HWND hWndNewViewer) But in my scenario, I need my program run background as a service to

Windows service: Listening on socket while running as LocalSystem

和自甴很熟 提交于 2021-01-27 13:14:40
问题 I'm writing a small server-like program in C for Windows (using MinGW/GCC, testing on Windows 7) which is eventually supposed to run as a service with the LocalSystem account. I am creating a socket, and using Windows Sockets bind() , listen() and accept() to listen for incoming connections. If I run the application from the command line (i.e. not as a service, but as a normal user), I have no problems connecting to it from external IPs. However, if I run the program as a service with the

How to open cmd from windows service?

最后都变了- 提交于 2021-01-27 05:44:08
问题 I am creating a Windows Service and using C#. I want open cmd.exe from the service. My operating system is Windows 8. Is it possible from a Windows Service, or is there another alternative for that. (I want to open cmd.exe after some interval - that's why I chose a windows service) 回答1: This won't work. Problem is that you are trying to show UI (Console) from a Windows Service and Windows Service is not running in the context of any particular user. Starting from Vista and later OS Windows

Dependency Injection in ASP.NET Core Worker Service

北慕城南 提交于 2020-12-31 20:06:36
问题 I'm facing some dependency injection issues in .NET Core Worker Service. Please see the below code in Program.cs file. public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsof)t", LogEventLevel.Warning) .Enrich.FromLogContext() .WriteTo.File(@"C:\MyApp_Log\Log.txt") .CreateLogger(); try { Log.Information("Starting up the service."); CreateHostBuilder(args).Build().Run(); return; } catch (Exception ex) { Log.Fatal(ex