windows-services

Credentials when Installing Windows Service

点点圈 提交于 2019-12-02 21:01:38
I am attempting to install a C# windows service project using a VisualStudio.Net deployment project. To run the deployment project I right-click and select "install" from the context menu, the install wizard runs and eventually prompts me with a "Set Service Login" dialog which asks for username & password. When I install a service using the sc utility from the command line, I don't have to provide credentials. Do I have to create a login just for this service? I'd prefer to use "Local System" or "Network Service" (not sure what the difference is) as other services do. anthares Add this code

Create a combo command line / Windows service app

倾然丶 夕夏残阳落幕 提交于 2019-12-02 20:54:41
What's the best way in C# to set up a utility app that can be run from the command line and produce some output (or write to a file), but that could be run as a Windows service as well to do its job in the background (e.g. monitoring a directory, or whatever). I would like to write the code once and be able to either call it interactively from PowerShell or some other CLI, but at the same time also find a way to install the same EXE file as a Windows service and have it run unattended. Can I do this? And if so: how can I do this? Mike Dinescu Yes you can. One way to do it would be to use a

How to make windows service application so it can run as a standalone program as well?

心已入冬 提交于 2019-12-02 20:46:58
I'll start with an example: Apache web server (under Windows) has a nice feature: it can be both run as a standalone application (with current users privileges), and that it can be installed and run as a windows service directly (as local system account), using same executable. In order for application to be run as a standalone app, all it needs to do is along the lines of having static public Main() in some public class. In order for application to be installable and runnable as service, it has to implement ServiceBase and Installer classes in certain way. But, if application like this is run

Communication between Windows Service and Desktop Application

时光总嘲笑我的痴心妄想 提交于 2019-12-02 20:45:41
I know that similar questions have been asked before, but even after all my Googling I'm still completely lost. I've written a small Windows Service that does what my main application used to do in a background thread (it made sense to move it to a separate service for several reasons). When the background thread was running as a part of my application it would fire an event every time it finished working (updating a database, in this case) and I would use a timestamp from that event to grab the appropriate information to update the window. I don't think the specifics are relevant, but please

Windows Service Choose User or System Account on Install

半城伤御伤魂 提交于 2019-12-02 20:40:52
When installing a windows service, is there a way to let the user installing choose between a specific user account and a computer account, such as LocalSystem? I see how to do this at build time through service installer properties, but not during install. @Doobi, @Eric, in my experience (Win7Home 64-bit, VS2010Express, not on a domain) processInstaller.Account = ServiceAccount.LocalService; processInstaller.Username = null; processInstaller.Password = null; will install the service as LocalService without a password prompt. To install the service as a local user account (and provide a

Why does Windows Service not launch external App?

五迷三道 提交于 2019-12-02 20:02:39
问题 I am trying to get a Windows Service to launch an external application. When I start my service it doesn't load the application up. There are no errors reported in the event view either. It just says the service started and stopped successfully. The following is the OnStart and OnStop code: public partial class TestService : ServiceBase { public Process App { get; set; } public TestService() { InitializeComponent(); App = new Process(); } protected override void OnStart(string[] args) { App

Windows service - get current directory

醉酒当歌 提交于 2019-12-02 19:58:22
I have a Windows service that should look for a configuration file in its current directory. So I use directory.getcurrentdirectiry() but instead of the service directory I get back c:\windows\system32 Any idea why and how should I get the service directory? Don't use Directory.GetCurrentDirectory() . I had the same exact problem with C:\Windows\System32 being returned. Use this instead: Path.GetDirectoryName(Application.ExecutablePath); You can set the current directory to the directory that your service is running from by including this line in your code: System.IO.Directory

Start python .py as a service in windows

主宰稳场 提交于 2019-12-02 19:43:12
I've created a windows service to start a .py script. sc create "Maraschino" binPath= "C:\HTPC\Maraschino\maraschino-cherrypy.py" DisplayName= "Maraschino" depend= "Tcpip" Then I've added a registry key to link the .py to open using python.exe Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Maraschino\Parameters] "AppDirectory"="C:\\Python27" "Application"="C:\\Python27\\python.exe C:\\HTPC\\Maraschino\\maraschino-cherrypy.py" However when I try start the service I get Error 193 0xc1 which when googled revealed that it isn't a valid exe I'm trying to

How configure log4net for a c# Windows service

ε祈祈猫儿з 提交于 2019-12-02 19:29:04
I have a windows service where the app.config file and the log4net.config files are seperate. The logging is not working. In my app.config file, I have the following in the section: <add key="log4net.Config" value="log4net.config"/> This works if in the value I specify an absolute path to the log4net.config file. Do I need to supply an absolute path to the log4net.cong? Both the log4net.config and app.config file are in the same folder as the executable. any ideas? Parag Maybe this is helpful ( Moving your Log4Net configuration out of web.config with ASP.NET 2.0 web sites .). Here are the

Should I host my WCF service in IIS?

我的梦境 提交于 2019-12-02 19:20:24
So I'm designing a WCF service. I'm unexperienced with WCF, and I'm trying to decide whether it should be hosted in IIS, or a custom Windows service.. Or some other option? Things to consider: It needs to load data from a database on startup. It needs to maintain this data across requests, not load it each time. It needs to process multiple requests simultaneously. It needs to be as configurable as possible regarding endpoints. It will be calling native dlls quite a lot. I suspect hosting it in IIS would simplify certain things, but I'm not sure it would be a good idea in this situation. What