RestSharp Timeout not working

Solution (Version 107+) var options = new RestClientOptions(“baseURL”) { ThrowOnAnyError = true, Timeout = 1000 // 1 second – thanks to @JohnMc }; var client = new RestClient(options); Older Versions: to alter the default time out to: 5 seconds – for example – (i.e. 5000 milliseconds): var client = new RestClient(“BaseUrl”); client.Timeout = 5000; // … Read more

Accessing Environment Variables from Windows Services

I’ve no idea if this is useful, but I’ve found that for every service, there is an option to add environment variables directly to a service. It is done via the registry. Say the key to your service is … HKLM\SYSTEM\CurrentControlSet\Services\YourService Create a REG_MULTI_SZ called Environment. Now you can add entries like … Var1=Value1 Var2=Value2 … Read more

Using Process.Start() to start a process as a different user from within a Windows Service

I seem to have a working implementation (Works On My Machine(TM)) for the following scenarios: Batch File, .NET Console Assembly, .NET Windows Forms application. Here’s how: I have a windows service running as the Administrator user. I add the following policies to the Administrator user: Log on as a service Act as part of the … Read more

Hosting ASP.NET Core as Windows service

You’ve got a couple of options here – use Microsoft’s WebHostService class, inherit WebHostService or write your own. The reason for the latter being that using Microsoft’s implementation, we cannot write a generic extension method with a type parameter inheriting WebHostService since this class does not contain a parameterless constructor nor can we access the … Read more

Windows Service System.Timers.Timer not firing

Here is my work-around… After way too many hours searching for an answer to this, I discovered a wide variety of articles and blogs discussing timers in Windows services. I’ve seen a lot of opinions on this and they all fall into three categories and in descending order of frequency: Don’t use System.Windows.Forms.Timer because it … Read more

How to change user credentials of windows service from command line?

sc.exe config “Service Name” obj= “DOMAIN\User” password= “password” type= own See Shortcut Setting Log-On Credentials for Windows Services ยป jonathanmalek.com. @MattT points out that on Windows Server 2008R2 you have to add type= own, but prior to that version it isn’t necessary. In PowerShell 3+, you can avoid escaping the arguments with the stop-parsing symbol: … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)