windows-services

How to communicate with a windows service from an application that interacts with the desktop?

随声附和 提交于 2019-12-17 07:31:30
问题 With .Net what is the best way to interact with a service (i.e. how do most tray-apps communicate with their servers). It would be preferred if this method would be cross-platform as well (working in Mono, so I guess remoting is out?) Edit: Forgot to mention, we still have to support Windows 2000 machines in the field, so WCF and anything above .Net 2.0 won't fly. 回答1: Be aware that if you are planning to eventually deploy on Windows Vista or Windows Server 2008, many ways that this can be

How to have a loop in a Windows service without using the Timer

不羁岁月 提交于 2019-12-17 07:13:34
问题 I want to call a Business layer method from a Windows service (done using C# and .NET) after every 10 seconds. However, i dont want to use the Timer_Elapsed event since it starts up another thread/process if the first thread/process is still running. I just need a single threaded approach, since multiple calls to the same Business method creates unwanted complications. So i added a do--while loop in the on_start. I know this is not the correct way since it spawns this process which becomes an

How to create windows service from java jar?

拜拜、爱过 提交于 2019-12-17 07:12:32
问题 I have an executable JAR file. Is it possible to create a Windows service of that JAR? Actually, I just want to run that on startup, but I don't want to place that JAR file in my startup folder, neither in the registry. 回答1: This article should tell you all you need to know: "Running Java Applications as a Windows Service"; it mentions using "Java Service Wrapper" (there is a community edition called YAJSW) 回答2: The easiest solution I found for this so far is the Non-Sucking Service Manager

Global Keyboard Hook from windows service

微笑、不失礼 提交于 2019-12-17 06:51:24
问题 Is it possible to write a global Keyboard Hook from windows(xp and 7) service ? ( using SetWindowsHookEx didn't work from a system service ) 回答1: The documentation for SetWindowsHookEx says: or with all threads in the same desktop as the calling thread. So you need to be associated with the same desktop (and there will be multiple desktops even without considering terminal services: the normal desktop, the secure desktop (used for UAC and login) and the screen saver). Since services are not

How can a Windows Service determine its ServiceName?

此生再无相见时 提交于 2019-12-17 06:14:08
问题 I've looked and couldn't find what should be a simple question: How can a Windows Service determine the ServiceName for which it was started? I know the installation can hack at the registry and add a command line argument, but logically that seems like it should be unnecessary, hence this question. I'm hoping to run multiple copies of a single binary more cleanly than the registry hack. Edit : This is written in C#. My apps Main() entry point does different things, depending on command line

How can I programmatically stop/start a windows service on a remote box?

泪湿孤枕 提交于 2019-12-17 04:29:55
问题 I want to write a console or Click Once WinForms app that will programmatically stop and/or start a windows service on a remote box. Both boxes are running .NET 3.5 - what .NET API's are available to accomplish this? 回答1: in C#: var sc = new System.ServiceProcess.ServiceController("MyService", "MyRemoteMachine"); sc.Start(); sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Running); sc.Stop(); sc.WaitForStatus(System.ServiceProcess.ServiceControllerStatus.Stopped); 回答2: You can

Windows service with timer

我的未来我决定 提交于 2019-12-17 04:29:14
问题 I have created a windows service with timer in c#.net. it works fine while i debug/build the project in visual studio but it does not perform its operation after installation. What might be the reason behind this ? code : public partial class Service1 : ServiceBase { FileStream fs; StreamWriter m_streamWriter; Timer tm = new Timer(); public Service1() { InitializeComponent(); this.ServiceName = "timerservice"; tm.Interval = 2000; tm.Tick += new EventHandler(PerformOperations); tm.Start(); fs

How to run console application from Windows Service?

时光总嘲笑我的痴心妄想 提交于 2019-12-17 03:35:56
问题 I have a windows service, written in c# and I need to run a console application from it. Console application also written in c#. Console application is running fine when it is run not from windows service. When it is ran from ws it doesn`t do anything it should and as it should work for 10-20 seconds I see in debug code is executed at once. I`m starting my console app with the following code: proc.Start(fullPathToConsole, args); proc.WaitForExit(); the path to console is right and when I`m

Using Process.Start() to start a process as a different user from within a Windows Service

◇◆丶佛笑我妖孽 提交于 2019-12-17 03:26:50
问题 I'd like to periodically run an arbitrary .NET exe under a specified user account from a Windows Service. So far I've got my windows service running with logic to decide what the target process is, and when to run it. The target process is started in the following manner: The Windows Service is started using "administrator" credentials. When the time comes, an intermediate .NET process is executed with arguments detailing which process should be started (filename, username, domain, password).

How can a Windows Service start a process when a Timer event is raised?

落爺英雄遲暮 提交于 2019-12-17 03:19:37
问题 I have created a Windows Service with Timer and in firing event of timer.Elapsed I am creating a process ( System.Diagnostics.Process.Start(exe path) ) at interval of 5 seconds. But this process does not get created on the firing of an event. Is there any other way of doing this? Thanks in advance. private void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { Process pr = new Process(); pr.StartInfo.FileName = @"C:\Program Files\Messenger\msmsgs.exe"; pr.StartInfo.WindowStyle