windows-services

LogonUser -> CreateProcessAsUser from a system service

I've read all the posts on Stack Overflow about CreateProcessAsUser and there are very few resolved questions, so I'm not holding my breath on this one. But it seems like I'm definitely missing something, so it might be easy. The target OS is Windows XP. I have a service running as "Local System" from which I want to create a process ru...

Best way to keep a .net client app updated with status of another application

I have a Windows service that's running all the time, and takes some action every 15 minutes. I also have a client WinForms app that displays some information about what the service is doing. I'd like the forms application to keep itself updated with a recent status, but I'm not sure if polling every second is a good move performance-wis...

Can the LocalSystem account impersonate any user ? Even if the user is not logged on ?

Hi, I have a Windows service running as LocalSystem that needs to access some network resources. I found a way to impersonate a user that is currently logged on, by retrieving the token with OpenProcessToken, duplicating it and calling WindowsIdentity.Impersonate. That way I can access the same network resources as the impersonated user...

Windows service - supplying arguments in "path to executable"

I cannot figure out how to pass (constant) arguments into my Windows service when it is started. I'm using the standard .NET classes like ServiceBase to implement (and ServiceProcessInstaller and ServiceInstaller to install) my service. On the general tab of a Windows Service properties dialog box (once installed), there's a "Path to ex...

Installer can't remove previous version

I use a visual studio setup & deploy project to install my components of my application. This has worked sucessfully with other applications and to allow the current version to install over the top of previous versions usually means just setting a property on the install project namely RemovePreviousVersions and setting that to true. I...

How to remotely control a Windows Service with ServiceController?

Hi, I'm trying to control Windows Services that are installed in a remote computer. I'm using the ServiceController class. I have this: ServiceController svc = new ServiceController("MyWindowsService", "COMPUTER_NAME"); With this, I can get the status of the Windows Service like this: string status = svc.Status.ToString(); But I...

Installer won't remove windows service

When I try to install over a previous version I get the error "The specified service already exists" I stop the service before the installation and the services.msc snap-in is closed also. I use a visual studio setup and deployment project. ...

How do I wait for a service/process to start before continuing a batch script?

I am writing a windows batch script to uninstall some software. However I need to wait after the uninstaller has finished for a service to be restarted before continuing with the next uninstall. I can make the script wait for the uninstaller to finsh using:- for /f "usebackq" %%M in ('tasklist /nh /fi "imagename eq %process_1%"') do...

Activate / deactivate windows NT-Server on Remotemachine

Hi, I need some help with Windows NT-Services. I have some services installed on a remote machine which I need to monitor and control from my local machine. With the ServiceController Class I can control the service, e.g. starting, stopping and so on. I also get the state of the Service via the ServiceController Class (Running, stopped...

Why Does VS2010 "Lose" my reference on build?

I've developed a class library that does stuff, and tested it with unit tests. The library and tests build and work fine. I then added in a Windows Service project to the solution to wrap the library up in. I've added a reference to my class project, added a using statement and var'd an object from the class lib. It colour-codes just fi...

C# WMI, Performance Counters, & SNMP Oh My!

I have a C# windows service which listens to a MSMQ and sends each message out as an email. Since there's no UI, I'd like to offer an ability to monitor this service to see things such as # messages in queue, # emails sent (by message type perhaps), # of errors, etc. What is the best/recommended way to accomplish this? Is it WMI or pe...

How to create a Task Scheduler App.

I have been task with (ha) creating an application that will allow the users to schedule a command line app we have with a parameter. So the command line app takes an xml and "runs it" So bottom line I either need to create a windows service or learn how to interact with the Task Scheduler service already running on the box (version 1 ...

Writing exceptions in multihreaded windows service to event log

I have a multithreaded windows service that will unpredictably stop running once every 24 hours or so. I am writing to the event log and that's going through just fine, but whenever the service crashes there are no messages in the event log (even that the service stopped, despite having AutoLog=true). Is there a way to have uncaught exce...

Windows Service starting error

The service was started then stopped.Some services automatically stop if there is no work to do? I've tried clearing all event logs but the error still persists. ...

Windows service and default code page/culture setting?

Hi, I'm writing a service that will read a file from a directory, read the contents of the file and process the content. I am having issues with Swedish characters that are read from the file as they are beeing translated into "garbage chars" by the service when they are read. Does anyone know what default code page/culture setting is...

ASP.NET Service - Web or Windows?

I'm looking for a method in which an application I will be hosting will have the ability to run a tasks on a giving interval of x minutes to check a database and send out reminder emails automatically. This would of course be based upon a scenario in which someone has scheduled a meeting, let's say, on a day and the service's job would b...

Which "platform" should we use for a notifier-component?

Hi all We need to develop a notifier component. What it will do, is to scan a database at given intervals (say, every 15th minute), to see if any notifications needs to be sent out. We're running on Windows, and so we've been looking into either a Windows Service or the Windows Task Scheduler. Our biggest concern is the robustness of ...

When querying the Win32_NTLogEvent Class from WMI with WQL is the TimeGenerated property based on Local time of the computer or GMT?

I am writing a C# windows service that is doing some churning through the eventlog on a few domain controllers. Some of them are Windows Server 2003 and some are Windows Server 2008. Upon the service stopping I am attempting to resume where I left off in the logs. In order to do this instead of SELECT * FROM Win32_NTLogEvent WHERE --cr...

Perform lengthy initialization in Windows Service

What's the best way to do some lengthy initialization when a Windows service starts up (or resumes from being paused) without blocking the Service Control Manager? ...

Playing voice over modem from a Windows service

I'm developing a VB.NET Windows service which is costantly checking a BMS database for new alarms and making phone calls to warn operators remotely. I'm currently using a .NET TAPI wrapper and the SAPI 5.3 interop assembly, and the steps I'm taking to speak over the phone are: Initialize TAPI interface; Make the call to the operator's ...