windows-services

Nested Transaction issues within custom Windows Service

I have a custom Windows Service I recently upgraded to use TransactionScope for nested transactions. It worked fine locally on my old dev machine (XP sp3) and on a test server (Server 2003). However, it fails on my new Windows 7 machine as well as on 2008 Server. It was targeting 2.0 framework; I tried targeting 3.5 instead, but it still...

Relative Path issue with .Net Windows Service..?

I have a windows service which is trying to access an xml file from the Application directory. Windows Service Installed directory : C:\Services\MyService\MyService.exe Path of the xml file : C:\Services\MyService\MyService.xml I am trying to access the file using the following code. using (FileStream stream = new FileStream("MyServi...

Install windows service "Service ... was not found on computer '.'."

I'm trying to create my first Windows Service in C# VS2010 and slowly discover how I should do things. But now I have reached a point, where I cannot install a new version of my service. My setup program tells me Error 1001. Service MyService was not found on computer '.'. --> The specified service does not exists as an installed servic...

How cancel shutdown from a windows service C#

Hello everybody I have a windows service started (written in C# .net2.0). I want to detect when the computer shutdown/reboot and cancel it. After the cancel I want do some actions and restart windows. I have tried it, but it not working using Microsoft.Win32; partial class MyService: ServiceBase { protected override void OnStart(...

Drawing with GDI+ under IIS

I'm running a web application under IIS that we draw graphs with that are sent to the clients. We were previously running under iis6, while migrating to 2008 ( iis7 ) we have encountered some very weird issues with the graphing. I stumbled across the msdn docs for GDI+ stating that "GDI+ functions and classes are not supported for use ...

how to get phyiscal path of windows service using .net?

I have to get the absolute path of a windows service in a .Net Admin application. I am using ServiceController of .Net as shown below. ServiceController serviceController = new ServiceController(serviceName); But I don't see any property here to get the absolute path of the .exe of the service. Is there anyway to get this programmati...

How to read file from the installation folder of app using c#?

Hi I am reading a file using File.ReadAllText("filename.txt"). This file is located in very same folder where the .exe file is located (c:/program files/installation folder). But windows app looks into System32 folder for this file by default. **I don't want to hard code the path of the file. ...

what to use for repetitive (daily, weekly, monthly) tasks ? Workflows, Windows Services, something else?

I've been writing Windows Services for a while and they always seem to work fine for things that need to run every day, few times a week, once a month, etc. but I've been lately thinking about going with Windows Workflow Foundation. However, I am unsure how would they run on a server without some container application (for instance Shar...

.Net Windows Service Throws EventType clr20r3 system.data.sqlclient.sql error

I have a .Net/c# 2.0 windows service. The entry point is wrapped in a try catch block that notifies me of problems and allows the service to continue operating normally yet when I look at the server's application event log I see a number of "EventType clr20r3" errors that are causing the service to die unexpectedly. The catch block has...

Sending message to windows service by web page

Hello, How could I do this with no access denied problem? I have a windows service: protected override void OnCustomCommand(int command) { if (command == 1) { foreach (Process traceProcess in Process.GetProcessesByName("notepad.exe")) { traceProcess.Kill(); } } } when I do...

Running mongod as a windows service

Hello, i have installed mongodb on win32 and i am trying to run it as a service. I have followed the instructions posted here: http://www.deltasdevelopers.com/post/Running-MongoDB-as-a-Windows-Service.aspx but when when windows tries to 'load'/'run' the service there is a problem. I see the service under the services control banner co...

How can a program tell if another process is running as a service?

I have a Win32 program which I can direct to monitor another Win32 process. I want to find a way for the monitoring program to determine if the monitored process is running as a Win32 service. Not all services run as SYSTEM and not all services have services.exe as a direct parent, so I don't regard these obvious techniques as being ro...

How do I subscribe to a MSMQ queue but only "peek" the message in .Net?

We have a MSMQ Queue setup that receives messages and is processed by an application. We'd like to have another process subscribe to the Queue and just read the message and log it's contents. I have this in place already, the problem is it's constantly peeking the queue. CPU on the server when this is running is around 40%. The mqsvc.e...

How to Synchronize Windows Service Access to SQL Server Database on Startup?

I have a WCF service that is running as a windows service. As soon as the WCF service starts it will try to connect to the DB and do some initialization processing. I'm having an issue when I restart my machine (the wcf service is set to start automatically), the service would get an exception as too sql is busy. So it seems like the s...

Service not able to access a mapped drive.

Hi All, I have read in many forums that mapped drives are not accessible from a service as no user is logged on. Question 1) I tried making my service as a log on - as some account and i had my network drive mapped in that very account. The service still cannot access it. Why? Question 2) From the same sevice, i invoke another process...

How to check the existence of a windows service in batch file

How can I check the existence of a windows service in a batch file? The user is inputing a service name and I want to check that the service does exist before continuing with my script. ...

Why Flash can't be rendered in a Windows Service?

I'm trying to solve a similar problem as was described here - to create a Windows Service for taking snapshots of rich webpages (html+js+flash) and saving them to a PDF file. The bundle Firefox+cmdlnprint did the trick for me. I wrote a simple program running as a service that invokes Firefox to make a PDF. All seems well, the PDF gets ...

Start a disabled windows service?

How do I start a disabled windows service from command line NET START "Service" doesn't work on disabled services ...

Cannot attach to a service in VS 2008

I have created a service in VS 2008 called EmailReader. I have compiled, installed and started the service. Its timer loop is writing records to a log file, so I can see that it is running. I am trying to attach to it in VS 2008, but the process name is greyed out in the list of available processes, and the name is "EmailReader.vshost.ex...

Checking only "Automatic" services with powershell.

I've seen lots of scripts out there for manually stopping/starting services in a list, but how can I generate that list programatically of -just- the automatic services. I want to script some reboots, and am looking for a way to verify that everything did in fact start up correctly for any services that were supposed to. ...