Here is an easy way to get the status of a Windows service. ''' <summary> ''' Gets the status of a Windows service. ''' </summary> ''' <param name="serviceName">Name of the service.</param> ''' <returns>ServiceControllerStatus.</returns> ''' <exception cref="InvalidOperationException">Service not found.</exception> ''' <exception cref="System.InvalidOperationException">Service not found.</exception> Public Function ServiceStatus(serviceName As String) As ServiceControllerStatus Dim service As ServiceController = LoadService(serviceName) If service IsNot Nothing Then Return service.Status Else Throw New InvalidOperationException("Service not found.") End If End Function ''' <summary> ''' Loads the service. ''' </summary> ''' <param name="serviceName">Name of the service.</param> ''' <returns>ServiceController.</returns> Private Function LoadService(serviceName As String) As ServiceController Return ServiceController.GetServices().Where(Function(p) p.ServiceName = serviceName).FirstOrDefault() End Function Here are the values for service status: ContinuePending Paused PausePending Running StartPending [...]
Want to add speech to any of your apps running in Windows? It's pretty easy using the SpeechSynthesizer in the .NET Framework. You can see this code in action in my Visual Studio backup or cleaner apps. I use text to speach to notifiy the user what the app is up to without having to [...]
Do you need to see if a process is already running? It's pretty easy with the code below. I wrote this code for my console apps .NET back utility and .NET file cleaner utility. ''' <summary> ''' Check to see if the current app is already running. ''' </summary> ''' <returns><c>true</c> if app is not running, <c>false</c>.</returns> Public [...]
There are a number of ways to compress things in .NET, but I found out that only the code below works for files. I wrote the code below for my console apps .NET back utility. Imports System.IO.Compression ''' <summary> ''' Compresses the file. ''' </summary> ''' <param name="sourceFileName">Name of the source file.</param> ''' <param name="destinationFileName">Name of [...]
Do you need to kill (stop) a process running on Windows?
The dotNetTips.DevBackup is a console tool that will quickly backup your Visual Studio code files. I wrote this app to backup source files before retrieving source from source control and at the end of the day. Note: It's recommended to close all instances of Visual Studio before running this app. This app will also stop [...]
The dotNetTips.Dev.Cleaner is an app that will quickly remove temporary and cached files created by Visual Studio and SQL Server. The reason I created this app is because from time to time Visual Studio builds will error for some unexplained reason, especially after getting new source from source control. It's because these temporary and cached files [...]