windows-services

Cannot Start Windows Service in NetworkService account

我们两清 提交于 2019-11-26 21:21:16
问题 I have a windows service project implementation that I am trying to install as network service. process = new ServiceProcessInstaller(); process.Account = ServiceAccount.NetworkService; however whenever I try to start the service I get : System error 5 has occurred. Access is denied. This comes after running the net start MyService command in the visual studio command prompt which is running as administrator by the way. Any help on how to get this to work? Thanks. 回答1: I would check that the

Install a Windows service using a Windows command prompt?

走远了吗. 提交于 2019-11-26 21:09:20
I want to install a Windows service using a Windows command prompt (not the Visual Studio command prompt). How do I do this? Navigate to the installutil.exe in your .net folder (for .net 4 it's C:\Windows\Microsoft.NET\Framework\v4.0.30319 for example) and use it to install your service, like this: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\installutil.exe" "c:\myservice.exe" Nothing wrong with SC Create command. Just you need to know the correct args : SC CREATE "MySVC" binpath= “D:\Me\Services\MySVC\MySVC.exe" Dhanuka777 If the directory's name has a space like c:\program files\abc 123 ,

FileSystemWatcher Fails to access network drive

你。 提交于 2019-11-26 21:06:14
I am trying to run a file watcher over some server path using windows service. I am using my windows login credential to run the service, and am able to access this "someServerPath" from my login. But when I do that from the FileSystemWatcher it throws: The directory name \someServerPath is invalid" exception. var fileWatcher = new FileSystemWatcher(GetServerPath()) { NotifyFilter=(NotifyFilters.LastWrite|NotifyFilters.FileName), EnableRaisingEvents=true, IncludeSubdirectories=true }; public static string GetServerPath() { return string.Format(@"\\{0}", FileServer1); } Can anyone please help

Is it possible to install multiple instances of the same delphi service application?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-26 21:01:43
问题 I have a service application built in Delphi that works great. It does exactly what I want it to do and all is happy. All is fine until I want to run two (or more) instances of that service on a single machine. Since the service name is hard coded into the program (via the Name property of the service), I can only install the service once on any given computer. If I try to modify the Name property at run-time, the service does not respond unless the Name property is set to the same thing that

how to delay shutdown and run a process in window service

末鹿安然 提交于 2019-11-26 20:50:27
I have to run a process ie a application on windows shutdown, is there any method to delay the windows shutdown and run the application in windows service... protected override void OnShutdown() { // Add your save code here // Add your save code here StreamWriter str = new StreamWriter("D:\\Log.txt", true); str.WriteLine("Service stoped due to on" + DateTime.Now.ToString()); str.Close(); base.OnShutdown(); } I have used function above which overrides the shutdown and i was able to write a log entry to a text file but i was not able to run an application after that On searching i found that the

EventLog write permissions

删除回忆录丶 提交于 2019-11-26 20:48:28
问题 My question is related to write permissions to the Windows Event Log. I have looked around several posts concering this, and have found some ways to solve my problem, but none of these are acceptable for my current scenario. I use C# in .NET 4.0. I use the EventLog class: EventLog class In short, I need to see if there is a way to impersonate or authenticate with an authenticated user and password to reach the right I need to write to the Event Log. The server will always be in the Windows

Starting a process with credentials from a Windows Service

对着背影说爱祢 提交于 2019-11-26 20:38:40
I have a Windows service that runs as mydomain\userA. I want to be able to run arbitrary .exes from the service. Normally, I use Process.Start() and it works fine, but in some cases I want to run the executable as a different user (mydomain\userB). If I change the ProcessStartInfo I use to start the process to include credentials, I start getting errors - either an error dialog box that says "The application failed to initialize properly (0xc0000142). Click on OK to terminate the application.", or an "Access is denied" Win32Exception. If I run the process-starting code from the command-line

Impersonate user in Windows Service

泪湿孤枕 提交于 2019-11-26 20:13:46
问题 I am trying to impersonate a domain user in a windows service with the service logged in as the Local System Account. So far, I am only able to get this to work by logging the service and set the process using the user credentials, like the following. ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = CommandDetails.Command; startInfo.WorkingDirectory = Settings.RoboCopyWorkingDirectory; startInfo.Arguments = commandLine; startInfo.UseShellExecute = false; startInfo

Screen capture from windows service

落爺英雄遲暮 提交于 2019-11-26 20:06:11
问题 I've got DirectShow based screen capture software. Internally it calls CopyScreenToBitmap function to grab screen. Then the picture is compressed by ffdshow. It works fine as a desktop application, but as window service, on certain computers it does not work (black picture). I've set 'Allow service to interact with desktop' and run that service on current user account. Any ideas what could be wrong? I test it on windows XP, but it is expected to work on Vista and 7 as well. Yes it works as

Windows service stops automatically

↘锁芯ラ 提交于 2019-11-26 19:46:22
问题 I made a Window service and let it work automatically and under localsystem account, when the service starts it fires this message for me and then stops The [service name] service on local computer started and then stopped. Some Services stop automatically if they are not in use by another services or programs. What's the problem and what's the solution? 回答1: Either you are not starting any threads on the OnStart method to do work, or there is an exception raised within your OnStart method.