windows-services

Is there any way to start a GUI application from a windows service on Windows 7?

余生颓废 提交于 2019-11-26 11:32:37
问题 I have done a lot of searching to find a way to start a GUI application from a windows service on Windows 7. Most of what I have found is that with Windows 7 services now run in a separate user session and can not display any graphical interface to the current user. I\'m wondering is there is any kind of workaround or different way of accomplishing something like this? Can the service start a process in a different user session? 回答1: This change was made for a reason and not simply to annoy

What directory does a Windows Service run in?

☆樱花仙子☆ 提交于 2019-11-26 11:21:13
I've created a very simple .NET Windows Service and installed it using InstallUtil.exe utility. In the service I have a piece of code as such: if (File.Exists("test_file.txt")) { // Do something clever } I've created a file called test_file.txt in the same directory as the service but the commented part of the code is never being executed...? Jeff Services are started from an application called Service Control Manager. This application lives in the system directory %WinDir%\System32 On a Windows 7 Ultimate - 64 bits this path is actually : %WinDir%\SysWOW64 For more information see Service

Print html document from Windows Service without print dialog

百般思念 提交于 2019-11-26 11:07:18
问题 I am using a windows service and i want to print a .html page when the service will start. I am using this code and it\'s printing well. But a print dialog box come, how do i print without the print dialog box? public void printdoc(string document) { Process printjob = new Process(); printjob.StartInfo.FileName = document; printjob.StartInfo.UseShellExecute = true; printjob.StartInfo.Verb = \"print\"; printjob.StartInfo.CreateNoWindow = true; printjob.StartInfo.WindowStyle =

windows service vs scheduled task

一笑奈何 提交于 2019-11-26 11:05:02
What are the cons and pros of windows services vs scheduled tasks for running a program repeatedly (e.g. every two minutes)? Rebecca Update: Nearly four years after my original answer and this answer is very out of date. Since TopShelf came along Windows Services development got easy. Now you just need to figure out how to support failover... Original Answer: I'm really not a fan of Windows Scheduler. The user's password must be provided as @moodforall points out above, which is fun when someone changes that user's password. The other major annoyance with Windows Scheduler is that it runs

.NET Windows Service with timer stops responding

淺唱寂寞╮ 提交于 2019-11-26 11:04:32
问题 I have a windows service written in c#. It has a timer inside, which fires some functions on a regular basis. So the skeleton of my service: public partial class ArchiveService : ServiceBase { Timer tickTack; int interval = 10; ... protected override void OnStart(string[] args) { tickTack = new Timer(1000 * interval); tickTack.Elapsed += new ElapsedEventHandler(tickTack_Elapsed); tickTack.Start(); } protected override void OnStop() { tickTack.Stop(); } private void tickTack_Elapsed(object

Logoff interactive users in Windows from a service

血红的双手。 提交于 2019-11-26 10:59:28
问题 I\'m trying to figure out a way to log off users in local Windows sessions from a Windows Service written in C#. Here\'s the background to the problem: I need to manage the computer usage time of a set of users; when their allotted time expires I want to log them off. This is in the context of a W2K8 domain. Unfortunately the login time controls in Windows simply disconnect the user from server resources; there is no way to force their sessions to terminate via this method. My approach is to

Install Windows Service with Recovery action to Restart

妖精的绣舞 提交于 2019-11-26 10:21:06
问题 I\'m installing a Windows Service using the ServiceProcessInstaller and ServiceInstaller classes. I\'ve used the ServiceProcessInstaller to set the start type, name, etc. But how do I set the recovery action to Restart? I know I can do it manually after the service is installed by going to the Services management console and changing the settings on the recovery tab of the service\'s properties, but is there a way to do it during the install? 回答1: You can set the recovery options using sc.

Debug Windows Service

青春壹個敷衍的年華 提交于 2019-11-26 10:13:06
问题 Scenario I\'ve got a windows service written in C#. I\'ve read all the google threads on how to debug it, but I still can\'t get it to work. I\'ve run \"PathTo.NetFramework\\InstallUtil.exe C:\\MyService.exe\". It said the install was successful, however when I run \"Services.msc\", The service isn\'t displayed at all, anywhere. If I go into Task Manager, there is a process called \"MyService.vshost.exe\". Pretty sure that\'s not it, because it\'s a service, not a process. Can Someone Explain

Automatically start a Windows Service on install

亡梦爱人 提交于 2019-11-26 10:09:33
问题 I have a Windows Service which I install using the InstallUtil.exe. Even though I have set the Startup Method to Automatic, the service does not start when installed, I have to manually open the services and click start. Is there a way to start it either via the command line, or through the code of the Service? 回答1: In your Installer class, add a handler for the AfterInstall event. You can then call the ServiceController in the event handler to start the service. using System.ServiceProcess;

“Automatic” vs “Automatic (Delayed start)”

时光总嘲笑我的痴心妄想 提交于 2019-11-26 10:06:49
问题 When installing Windows services there are two options for automatically starting a Windows service on Windows startup. One is Automatic , and the other is Automatic (Delayed start) . What is the difference between these two in detail? For example, if you\'re creating the installer with wixtoolset, the ServiceConfig element has the DelayedAutoStart attribute. How will that effect what happens when services are started at boot time? WiX documentation: ServiceConfig Element 回答1: In short,