windows-services

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-11-28 07:00:06
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? Jeff Sternal You could try the technique described here , used at StackOverflow itself (or at least it was used here at one point). In a nutshell: At startup, add an item to the HttpRuntime.Cache with a fixed

Schedule machine to wake up

左心房为你撑大大i 提交于 2019-11-28 06:58:18
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 using dialup or 3G wireless modem, so unfortunately it can't rely on Wake on LAN. You can use waitable

PsExec gets stuck on licence prompt when running non-interactively

那年仲夏 提交于 2019-11-28 06:43:27
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 around this silly limitation? Running on Windows Server 2008 R2 x64. Use the /accepteula command-line

Error 1001 when installing custom Windows Service

馋奶兔 提交于 2019-11-28 06:25:16
I wrote a windows service that runs on Framework 4.0 and running in VS 2015. I also created a setup project (free Installshield version). My service did not show under services.msc after I installed it, so according to some other posts I had to mark the Primary Output in InstallShield as 'Installer Class', but when I do that I get Error 1001 when I run the setup.exe. This post states that "Error code 1001 ALWAYS means a failure in the Installer class custom action." and that I should not use Custom Actions. I'm not using any custom actions at the moment. Most of the solution on this site have

Can you write Windows services in Powershell

自古美人都是妖i 提交于 2019-11-28 06:16:38
问题 I have written a program in PowerShell that loops and checks stuff. I would like to convert this into a Windows service. I've created a Windows service (in Admin->Services) but I can't start it. I'm pretty sure I'm missing the proper interface that the system needs to call into in order to start/stop/pause/etc the service. I can find plenty of examples when it comes to doing it in VB/C#/MS-lang but nothing about how to do it using PowerShell. Is there any documentation (or preferably code

How can I unit test a Windows Service?

Deadly 提交于 2019-11-28 06:08:35
.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 make any sense to me since I have never dealt with WCF service. I'd probably recommend designing your app

Best way to do a task looping in Windows Service

好久不见. 提交于 2019-11-28 05:59:37
I have a method that send some SMS to our customers that look like below: public void ProccessSmsQueue() { SmsDbContext context = new SmsDbContext(); ISmsProvider provider = new ZenviaProvider(); SmsManager manager = new SmsManager(context, provider); try { manager.ProcessQueue(); } catch (Exception ex) { EventLog.WriteEntry(ex.Message, EventLogEntryType.Error); } finally { context.Dispose(); } } protected override void OnStart(string[] args) { Task.Factory.StartNew(DoWork).ContinueWith( ??? ) } So, I have some issues: I don´t know how long it takes for the method run; The method can throw

Mongodb, sharding and multiple windows services

蹲街弑〆低调 提交于 2019-11-28 05:32:15
In order to get sharding to work I need to run two copies of mongod.exe. One as a shard and one as the config server. How can I install both mongod instances as windows services? The following command line will install a 2nd instance of Mongo DB. Note that you have to provide serviceName , serviceDisplayName , port , dbpath and logpath in order to avoid collisions. mongod --install --serviceName " Mongo DB 2nd instance " --serviceDisplayName " Mongo DB 2nd instance " --port 37017 --dbpath c:\data\db2 --logpath c:\data\logs\mongolog2.txt Then you just start the service with net start " Mongo DB

What is the best NHibernate session management approach for using in a multithread windows service application?

天涯浪子 提交于 2019-11-28 05:31:46
I have a windows service application that work with multithread. I use NHibernate in data access layer of this application. What is your suggestion for session management in this application. I read about UNHAddins, Is it a good solution? I use NHibernate's built in contextual sessions. You can read about them here: http://nhibernate.info/doc/nhibernate-reference/architecture.html#architecture-current-session Here is an example of how I use this: public class SessionFactory { protected static ISessionFactory sessionFactory; private static ILog log = LogManager.GetLogger(typeof(SessionFactory))

Can't start Windows service written in Python (win32serviceutil)

狂风中的少年 提交于 2019-11-28 05:28:36
I'm trying to start a simple service example: someservice.py: import win32serviceutil import win32service import win32event class SmallestPythonService(win32serviceutil.ServiceFramework): _svc_name_ = "SmallestPythonService" _svc_display_name_ = "display service" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): win32event.WaitForSingleObject(self.hWaitStop, win32event