windows-services

WMI call takes too much time when system Starts/ReStarts

[亡魂溺海] 提交于 2019-12-02 06:23:16
问题 I want to get the path of the Windows Service, var managementObjectSearcher = new ManagementObjectSearcher("Select * from Win32_Service where serviceName = MyService"); this code is written of the constructor of some other service... everything works fine when system is UP and running but if i restart the system put the StopWatch class for this call and it shows that it shows that the service takes 35-45 seconds to start because of this call.. Any suggestions to improve the performance on

Excel Automation Windows Service

自古美人都是妖i 提交于 2019-12-02 06:22:13
问题 I have a Windows Service that runs the Excel Interop in order to automate the execution of various macros. However, I am running in a peculiar issue when I try to run a macro which access a database using Windows Authentication ... If the macro is run through the Windows Service , the workbook is opened and the macro is execution is started but the application hangs (presumably at the data access portion). If, however, the macro is run through the Visual Studio debugger , using the same

Enabling/Disabling Aero from a Windows Service

耗尽温柔 提交于 2019-12-02 05:46:41
I have some code to enable/disable the Windows Aero service in Vista, and I would like to run it in a Windows Service. The code works in a standalone application, but when I run it from a Service, nothing happens. No errors or exceptions are thrown. I realise that running code in a service is a different scope than running code in an application, but in this case, how would I enable/disable Aero from the service? Is this even possible? Here is the code I am working with: public static readonly uint DWM_EC_DISABLECOMPOSITION = 0; public static readonly uint DWM_EC_ENABLECOMPOSITION = 1;

Create memcached service in windows failed

有些话、适合烂在心里 提交于 2019-12-02 05:26:26
问题 I'm using Memcached-for-Windows , see: http://blog.elijaa.org/index.php?post/2010/08/25/Memcached-1.4.5-for-Windows&similar I've tried to use: sc create "memcached" binPath="C:/memcached/mem cached.exe" start=auto but I can't create the Windows service, and no warning or error, just: Creates a service entry in the registry and Service Database. SYNTAX: sc create [service name] [binPath= ] <option1> <option2>... CREATE OPTIONS: NOTE: The option name includes the equal sign. type= <own|share

Accessing Google Drive from Windows service

拜拜、爱过 提交于 2019-12-02 04:47:13
I'm trying to understand if it's possible to access a Google Drive from a traditional Windows Service, without involving the user. Following the guides on https://developers.google.com/drive/quickstart , I've been able to create a command line application which uploads a file to Google Drive. However, this application launches the web browser and redirects me to Google's Authorization Server page which gives me an authorization code I have to enter in the command line app. Obviously this won't work for an application which is running as a Windows Service which will try to upload files to

How can I run an exe or windows service in medium trust?

笑着哭i 提交于 2019-12-02 04:45:45
I would like to run exes and Windows Services in Medium Trust, but all the literature I can find suggests using <system.web> <trust level="Medium"/> </system.web> for ASP.NET, so I have tried that but using code from How do you check if you are running in Medium Trust environment in .NET? it still appears to have full trust. What is the correct way to do this? The available approaches depend on the .NET version. Prior to .NET 4.0, the CLR enforced CAS policy, which made it possible to restrict permissions for any assembly. However, as of .NET 4.0, the CLR no longer applied CAS policy unless

Accessing shared folder over a network in windows service

六月ゝ 毕业季﹏ 提交于 2019-12-02 04:17:25
问题 I have a windows service that needs to access the files (sometime modification also) from a network (shared folder). I get the file name from an XML like, <add key ="FolderName" value="\\192.168.0.1\Source" /> I made a log file which always shows that the path is not found. Also i need to know how to debug a windows service using visual studio? Thanks in advance. 回答1: Most likely, the problem is in permissions to the shared folder. Your service runs under some user account and this account

InvalidCastException of a Activator.CreateInstance object during an installation procedure

浪尽此生 提交于 2019-12-02 03:49:36
I have the following procedure private static IMyInterface OpenInstance( string assemblyPath, string classType, string assemblyName, out AppDomain domainInstall) { IMyInterface interface = null; AppDomainSetup domaininfo = new AppDomainSetup(); domaininfo.ApplicationBase = assemblyPath; domainInstall = AppDomain.CreateDomain("PathInstall", null, domaininfo); ObjectHandle handleService = null; try { handleService = Activator.CreateInstance( domainInstall, assemblyName, classType, true, System.Reflection.BindingFlags.CreateInstance, null, new Object[] { assemblyName}, System.Globalization

Logstash-forwarder as Windows Service

纵饮孤独 提交于 2019-12-02 03:49:32
问题 I'm struggling to create a Windows Service for a logstash forwarder on Windows 2008 R2 Server. My setup looks as follows: Ubuntu Server 14.04 LTS Elasticsearch Logstash Kibana Windows Server 2008 R2: Application logging to a certain path. Ship logs to the ELK Stack via Logstash-forwarder I'm currently shipping logs successfully to the ELK-Stack via Logstash forwarder compiled for Windows using the instructions here... https://github.com/elastic/logstash-forwarder. The only problem is, that I

Calling ServiceBase.OnStart and OnStop… same instance?

[亡魂溺海] 提交于 2019-12-02 03:06:29
So I've got a Windows service written in c#. The service class derives from ServiceBase , and starting and stopping the service calls instance methods OnStart and OnStop respectively. Here's SSCE of the class: partial class CometService : ServiceBase { private Server<Bla> server; private ManualResetEvent mre; public CometService() { InitializeComponent(); } protected override void OnStart(string[] args) { //starting the server takes a while, but we need to complete quickly //here so let's spin off a thread so we can return pronto. new Thread(() => { try { server = new Server<Bla>(); } finally