windows-services

Stopping/Starting a remote Windows service and waiting for it to open/close

五迷三道 提交于 2019-11-26 17:57:36
问题 The top answer to this question tells me how to stop/start a remote service. Great. Now, all I need is to wait for the actual stop/start to complete. So, what I'm looking for is a dos command to: Start a service, should return only after the service is started (or after a timeout, raising error level) Stop a service, return only after the service is stopped 回答1: I created a set of batch scripts that use sc.exe to do just this. They are attached below. To run these scripts, you should be a

Install Windows Service created in Visual Studio

守給你的承諾、 提交于 2019-11-26 17:56:16
问题 When I create a new Windows Service in Visual Studio 2010, I get the message stating to use InstallUtil and net start to run the service. I have tried the following steps: Create new project File -> New -> Project -> Windows Service Project Name: TestService Build project as is (Service1 constructor, OnStart, OnStop) Open command prompt, run "C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe" TestService.exe Run net start TestService . Output of step 4 Running a transacted

Reading Excel Files as a Server Process

心不动则不痛 提交于 2019-11-26 17:51:20
I'm trying to find an appropriate way to read the contents of an Excel file on an NT server operating system. I have numerous problems using the Excel API and then came across the official Microsoft on Office Automation which states that the Excel API is not suitable for Excel automation. The sorts issues that I saw were similar to those described in the article. Is there another way that I can read an Excel file (xls, xlsx, xlsm) on a server (no UI) in such a way that doesn't suffer the same sort of threading/security/license issues imposed within the Excel API? There were a number of

Wix installer to replace INSTSRV and SRVANY for user defined service installation

感情迁移 提交于 2019-11-26 17:50:01
问题 I created an executable MyService.exe using Visual Studio C# Express. There are no options in the Express version to create a service. In the past, this has been manually installed as a user defined service using the INSTSRV and SRVANY as described in the MSDN Article 'How To Create a User-Defined Service' Is it possible to create a wix 3.5 installer for this file that doesn't require the existence of the SRVANY.exe and INSTRV.exe files on the target machine does not use INSTSRV.exe as a

Automating Office via Windows Service on Server 2008

本小妞迷上赌 提交于 2019-11-26 17:43:27
We have a Windows Service which runs on 2003 Server. It opens a source Word document using the Word Interop and then does some stuff with it. It also does likewise with Excel and PowerPoint files. Recently we've tried moving this service onto a Windows 2008 Server machine and are having real problems with it. COMException at Microsoft.Office.Interop.Excel.Workbooks.Open COMException at Microsoft.Office.Interop.Word.Documents.Open I get the above exceptions when the windows service is running on 2008 Server. Looking at the Task Manager, the application does load ok, but then closes again

How to communicate with a windows service?

梦想的初衷 提交于 2019-11-26 17:42:56
I want to create a windows service that validates data and access it from another windows application, but I'm new to services and I'm not sure how to start. So, while the service is running, a windows application should somehow connect to the service, send some data and get a response, true or false. user2750836 I could successfully handle the (almost) same issue as yours doing the following: In your Class : ServiceBase, that represents your Service class, you might have: public Class () //constructor, to create your log repository { InitializeComponent(); if (!System.Diagnostics.EventLog

Global exception handler for windows services?

穿精又带淫゛_ 提交于 2019-11-26 17:37:25
问题 Is there a way to globally handle exceptions for a Windows Service? Something similar to the following in Windows Forms applications: Application.ThreadException += new ThreadExceptionEventHandler(new ThreadExceptionHandler().ApplicationThreadException); 回答1: Here is some pretty robust code we advise people to use when they're implementing http://exceptioneer.com in their Windows Applications. namespace YourNamespace { static class Program { [STAThread] static void Main() { AppDomain

GUI and windows service communication

二次信任 提交于 2019-11-26 17:34:11
I know since Vista, that C# can't hook a UI form directly to the windows service. This was stated on the Microsoft Site. My question in this regard is: "What is the best mode of communication from a UI to the service?" I have heard of Remoting, Web services, and direct TCP. Are there other methods? How do they rank against the previously mentioned methods? How complicated are they to implement? My application is for intranet use, not internet. Microsoft platform will be on both sides, so interoperability is not a factor, but speed is. I mean I want to get across the smallest packet possible on

How do I get the currently-logged username from a Windows service in .NET?

99封情书 提交于 2019-11-26 17:22:31
I have a Windows service which need the currently logged username. I tried System.Environment.UserName , Windows identity and Windows form authentication, but all are returning " System " as the user as my service is running in system privileged. Is there a way to get the currently logged in username without changing my service account type? Tapas This is a WMI query to get the user name: ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT UserName FROM Win32_ComputerSystem"); ManagementObjectCollection collection = searcher.Get(); string username = (string)collection.Cast

Needed: A Windows Service That Executes Jobs from a Job Queue in a DB; Wanted: Example Code

痴心易碎 提交于 2019-11-26 17:05:27
问题 Needed: A Windows Service That Executes Jobs from a Job Queue in a DB Wanted: Example Code, Guidance, or Best Practices for this type of Application Background: A user will click on an ashx link that will insert a row into the DB. I need my windows service to periodically poll for rows in this table, and it should execute a unit of work for each row. Emphasis: This isn't completely new terrain for me. EDIT: You can assume that I know how to create a Windows Service and basic data access. But