windows-services

Getting full path for Windows Service

蹲街弑〆低调 提交于 2019-12-03 02:55:26
问题 How can I find out the folder where the windows service .exe file is installed dynamically? Path.GetFullPath(relativePath); returns a path based on C:\WINDOWS\system32 directory. However, the XmlDocument.Load(string filename) method appears to be working against relative path inside the directory where the service .exe file is installed to. 回答1: Try System.Reflection.Assembly.GetEntryAssembly().Location 回答2: Try this: AppDomain.CurrentDomain.BaseDirectory (Just like here: How to find windows

CreateProcessAsUser Creating Window in Active Session

不打扰是莪最后的温柔 提交于 2019-12-03 02:29:18
I am using CreateProcessAsUser from a windows service ( please can we stay on-topic and assume I have a very good reason for doing this ). Contrary to what everyone else is asking here I am getting a window in my active terminal session (session 1) instead of the same session as the service (session 0) - which is undesirable. I appropriated Scott Allen's code ; and came up with the following. Notable changes are the "revert to self", the "CREATE_NO_WINDOW" and command-line args support. using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Security;

Does one need to manually create a Windows event log source when installing a Windows service

元气小坏坏 提交于 2019-12-03 02:24:36
I have developed a Windows service in C#. I have created a installer with Visual Studio 2008, which installs the Windows service. Everything is good so far. I want to make sure that the event source has been created at install time, so that any error/exception conditions at runtime are correctly logged to the Windows event log. Does the event source get automatically created (and removed) as part of the windows service installation (and uninstallation), or do I have to handle this myself and create a custom action to create and delete it as follows? protected override void OnBeforeInstall

What exactly is CPU Time in task manager?

孤街浪徒 提交于 2019-12-03 02:20:54
I have some WCF services that are hosted in a windows service. Yesterday I looked at Task Manager and noticed that the CPU time for my windows service process was over 5 hours, while the majority of all other processes were at 0. What does that mean? Should I be concerned that the CPU Time was 5+ hours? CPU time is an indication of how much processing time that the process has used since the process has started (in Windows: link to a Technet article .) It is basically calculated by: CPU Time of Process = Process Uptime * CPU Utilization of Process For example, if the process has been running

Windows Service Install Ends in Rollback

孤街浪徒 提交于 2019-12-03 02:03:06
When I try to install a Windows service: c:\Windows\Microsoft.NET\Framework64\v4.0.30319\installutil I get, what looks to be, some success messages and some failure messages. Part way down: An exception occurred during the Install phase. System.ComponentModel.Win32Exception: The specified service has been marked for deletion At the end: The Rollback phase completed successfully. The transacted install has completed. The installation failed, and the rollback has been performed. The service is given an entry in the Services applet, but it is marked as "Disabled". When I attempt to change it to

How to change java_opts for tomcat when we run it as a windows service manually?

瘦欲@ 提交于 2019-12-03 01:51:29
I'm manually running tomcat 6 as a windows service on the console. I need to change java_opts before starting it. How do I do that? Also, Is there a way I can see the logs dynamically? To alter the $JAVA_OPTS , you will probably need to edit the batch file you use to start Tomcat. I don't run Tomcat on Windows, but the $JAVA_OPTS appears in my catalina.sh inside the bin/ directory on my Linux installation. As far as viewing logs dynamically on Windows, there are a couple of options I'm aware of. Download and install Cygwin, and then on the command-line, use tail -f logfilename like you would

Get appdata\\local folder path in C# windows service

蹲街弑〆低调 提交于 2019-12-03 01:40:48
I am try to get C:\Users\<username>\AppData\Local folder path using Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) in a C# Windows service, but it returns some other path C:\Windows\ServiceProfiles\LocalService\AppData\Local Does any have any idea how to do it correctly? Are you running the service under a user account? If not, the service will use its own profile as you see. If this service is "logged into" by a user, then you could pass the folder to the service and bypass local checking. Otherwise, try running the service under a user account (or create an account

py2exe windows service problem

一世执手 提交于 2019-12-03 01:38:32
I have successfully converted my python project to a service. When using the usual options of install and start/stop, everything works correctly. However, I wish to compile the project using py2exe, which seems to work correctly until you install the EXE as a service and try and run it. You get the following error message: Starting service CherryPyService Error starting service: The service did not respond to the start or control request in a timely fashion. My compile python file (which links to the main project) is as follows: from distutils.core import setup import py2exe setup(console=[

How do I fix 'Setup project with custom action file not found' exception?

帅比萌擦擦* 提交于 2019-12-03 01:19:11
I am trying to create a setup project for a Windows Service. I've followed the directions at http://support.microsoft.com/kb/816169 to create the setup project with no trouble. I want to be able to get a value during the installation in order to update the app.config with the user's desired settings. I added a Textboxes (A) dialog to retrieve the values. I set the Edit1Property property to "TIMETORUN", and in my Primary Output action's CustomActionData property I put in the following: /TimeToRun="[TIMETORUN]\" . So far so good. Running the setup I can retrieve the TimeToRun value from the

Best practice for writing a self-updating windows service

萝らか妹 提交于 2019-12-03 01:18:22
We need to create a windows service that has the ability to self update. Three options spring to mind, a second service that manages the retrieval, uninstallation and installation of the first service. Use of some third party framework (suggestions welcome. I believe .NET supports automatic updating for windows forms apps, but not windows services) Use of a plugin model, whereby the service is merely a shell containing the updating and running logic, and the business logic of the service is contained in a DLL that can be swapped out. Can anyone shed some light on the solution to this problem?