windows-services

How do I retrieve the username that a Windows service is running under?

两盒软妹~` 提交于 2019-12-17 18:35:40
问题 Given a service name, I would like to retrieve the username that it runs under (i.e. the username shown in the 'Log On' tab of a service's properties window). There doesn't appear to be anything in the ServiceController class to retrieve this basic information. Nothing else in System.ServiceProcess looks like it exposes this information either. Is there a managed solution to this, or am I going to have to drop down into something lower-level? 回答1: Using WMI, with the System.Management you can

Run a process from a windows service as the current user

醉酒当歌 提交于 2019-12-17 18:24:45
问题 I currently have a windows service that is running under the System Account. My problem is that i need to start certain processes from within the service as the current logged on user. I have all the code etc to get the current logged on user / Active session. My problem is that i need spawn a process as the logged on user but will not know the user credentials etc. The service is .net compiled service and i expect that i need to use some Pinvoke methods to get a handle of one of the current

Is there a way to run a process every day in a .Net web application without writing a windows service or SQL server jobs

一个人想着一个人 提交于 2019-12-17 18:24:13
问题 We require that in a ASP.Net application, a .Net process should be invoked every day at a specified time automatically. This process needs to interact with the database (SQL Server 2005) and generate billing on a daily basis. We are using a shared hosting hence we are not able to create a windows service or create SQL Server jobs. How can this be achieved without user intervention? 回答1: You could try the technique described here, used at StackOverflow itself (or at least it was used here at

Is there a way to run a process every day in a .Net web application without writing a windows service or SQL server jobs

给你一囗甜甜゛ 提交于 2019-12-17 18:22:16
问题 We require that in a ASP.Net application, a .Net process should be invoked every day at a specified time automatically. This process needs to interact with the database (SQL Server 2005) and generate billing on a daily basis. We are using a shared hosting hence we are not able to create a windows service or create SQL Server jobs. How can this be achieved without user intervention? 回答1: You could try the technique described here, used at StackOverflow itself (or at least it was used here at

Schedule machine to wake up

你。 提交于 2019-12-17 18:18:44
问题 What's the best way to programmatically cause a Windows XP (or above) machine to wake up at a specific time. (Ideally a lot like how Media Center can start up automatically to record a particular TV program) I've got a Windows service (written in C#) and I'd like this service to be able to cause the machine it is hosted on to start up at predetermined times. Are there any BIOS settings or prerequisites (eg. ACPI) that need to be configured for this to work correctly? This machine would be

PsExec gets stuck on licence prompt when running non-interactively

穿精又带淫゛_ 提交于 2019-12-17 18:11:28
问题 I have a Hudson build script which calls the SysInternals PsExec utility. Normally, when PsExec is run for the first time by a given user it pops up a dialog box asking the user to accept the licence. The build agent runs as a service and I can see that the build gets stuck at PsExec. Process Explorer shows that PsExec is running, so I strongly suspect it's displaying that same prompt, but because it's running non-interactively there is no way to accept the prompt. Is there any way to get

How can I unit test a Windows Service?

空扰寡人 提交于 2019-12-17 17:59:32
问题 .NET Framework: 2.0 Preferred Language: C# I am new to TDD (Test Driven Development). First of all, is it even possible to unit test Windows Service? Windows service class is derived from ServiceBase, which has overridable methods, OnStart OnStop How can I trigger those methods to be called as if unit test is an actual service that calls those methods in proper order? At this point, am I even doing a Unit testing? or an Integration test? I have looked at WCF service question but it didn't

Installing a windows service on remote machine using given username

好久不见. 提交于 2019-12-17 17:48:31
问题 What is the best way to install a windows service written in C# (in the standard way) on a remote machine, where I need to provide the username and password it should run as? I am going to run it from MSBuild as part of integration tests. EDIT: I don't have an msi and I don't want to create one. 回答1: You can use the SC command. sc.exe \\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe start= auto obj= DOMAIN\username password= pwd (Note the spaces after the equals

Start stop Service from Form App c#

落爺英雄遲暮 提交于 2019-12-17 17:39:57
问题 How can I start and stop a windows service from a c# Form application? 回答1: Add a reference to System.ServiceProcess.dll . Then you can use the ServiceController class. // Check whether the Alerter service is started. ServiceController sc = new ServiceController(); sc.ServiceName = "Alerter"; Console.WriteLine("The Alerter service status is currently set to {0}", sc.Status.ToString()); if (sc.Status == ServiceControllerStatus.Stopped) { // Start the service if the current status is stopped.

Cannot start MongoDB as a service

爱⌒轻易说出口 提交于 2019-12-17 17:29:03
问题 I have been developing for MongoDB for some months now and would like to install it as a service on my Windows 7 Enterprise machine. The following is the command that I have executed to create the service: "D:\Milvia Systems\Development\MongoDB\mongod.exe" --logpath "D:\Milvia Systems\Development\MongoDB\logs\DBLog.log" --logappend --dbpath "D:\Milvia Systems\Development\MongoDB\db" -vvv --reinstall However, whenever I use net start "MongoDB" or the Service Control Panel I receive the