Sr. Content Developer at Microsoft, working remotely in PA, TechBash conference organizer, former Microsoft MVP, Husband, Dad and Geek.
150215 stories
·
33 followers

How to Convert Any Executable or Batch file to Windows Background Service

1 Share
When working in software development or deployment environment. Sometimes converting an executable (.exe) tool or a batch file to a windows background service is necessary in order to avoid restarting the whole process again and again manually. This is helpful especially in production servers where in case of abrupt server restart, you don't require to rush into restarting a particular tool or a batch file. The windows background service will do the restarting of your installed service automatically, in case your server or system restarts. So, how can you achieve this?

Today, I shall demonstrate conversion of any executable (.exe) or batch (.bat) file into a windows background service using a powerful yet simple tool NSSM.

 


Prerequisites:

Before proceeding any further in this article, following are some of the many prerequisites for this article:
  1. Download NSSM tool.
  2. Knowledge of Batch (.bat) file.
  3. Knowledge of Windows Command Prompt.

Let's begin now.

1) First step is to download NSSM tool from its official website at your target location.

 
2) In the next step, extract the NSSM tool from the downloaded ZIP file at your target location, make sure to extract your machine's relevant version. I am using windows 64 bit version of NSSM tool for this article.
 
 
3) Now, open Windows Command Prompt as administrator and change into directory location where you have extracted the NSSM tool.

 
4) I have created a sample batch file that simply prints hello world for this article you can check the video demo for details. Now, type below command into windows command prompt for the installation of your windows background service i.e.

 

5) An installation window will appear. Provide relevant configurations within application, details and I/O tab and also enter name of your service and hit install service. You will get a successful installation message. 




6) To confirm that your service is successfully installed as windows background service. Open windows services window by typing below command within run window. Then search for your target service, which in my case is hello world. You can see that my batch file is successfully installed as windows background service. Start the service and make sure that it is in running state because this will confirm that your batch file is working fine. You can check the output in the output log file that you have configured in I/O tab of the NSSM tool during installation.
 
 


 

7) If you which to remove your service then first stop your service from windows services windows. Next, open the windows command prompt window as administrator and type below command with your service name. A confirmation message will appear. Click yes and you will receive a successful removal message. Refresh windows service window and you can see that your service is no longer available on your machine.

 


 

Conclusion

In this article, you will learn to convert any executable (.exe) or batch (.bat) file to windows background service using a simple yet powerful tool called NSSM. You will learn the entire installation process that includes installation and verification of your service. You will also learn to verify your successful windows service installation through windows services window. Finally, you  will learn to remove your service through NSSM tool.
 

Related Articles


Video


Read the whole story
alvinashcraft
24 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

C# 14 New Feature: Field-Backed Properties

1 Share

In this talk, Ian Griffiths explains how C# 14's new field-backed properties feature can save you from metaphorically falling off a cliff when you need more flexibility beyond automatic properties' basic functionality.

He demonstrates the use of this feature to customize property setters without losing the simplicity and support of automatic properties. By allowing you to refer to the compiler-generated field inside get or set methods, C# 14 reduces verbosity and maintains code clarity and organization.

Learn how this small but impactful enhancement can improve your C# coding experience.

  • 00:00 Introduction to C# 14's New Feature
  • 00:30 Understanding Automatic Properties
  • 01:11 Customizing Property Behavior
  • 03:06 Introducing C# 14's New Syntax
  • 04:21 Benefits of the New Feature
  • 05:33 Conclusion

C# 14 can save you from falling off a cliff with its new field-backed properties feature. Admittedly, the cliff is metaphorical. Sometimes when you're using a language or library feature, you can find yourself wanting to go beyond what that feature is able to support. And by moving outside the bounds of its support, you, so to speak, walk off the cliff and that sudden loss of support makes your life a lot harder.

Let me show you what I mean. I've got a very simple class here with a couple of properties. As you may know, this syntax where we use just the get and set keywords and optionally an accessibility modifier makes the compiler generate some code for us. It'll define a hidden field to hold the value and it supplies bodies for the get and set that use that field. The proper name for this is an automatically implemented property, but we typically shorten that to just auto property. This saves us from the tedious business of declaring a field and writing the obvious code to read and write the value in that field. It's not a huge deal, but if you're writing lots of properties, this offers worthwhile improvements in clarity and reduces work.

But what if we want slightly more than what C# generates for us? Notice this type defines an IsModified property. What if I want to set that anytime the Value property changes? Before C# 14, the only way to do that was to write a full property instead of an automatic property. Visual Studio can make that change for me. As you can see, this means declaring the field explicitly and having get and set accessors that use that field. Actually, Visual Studio doesn't quite get it right in this case because it hasn't noticed that the field name collides with the contextual keyword value inside the getter. So I need to qualify the field with a this reference.

And now this is almost identical to what the compiler was generating for me. I can now add in the extra feature that I wanted. So I'm just gonna adjust the layout and then use the full block syntax for the setter. And that gives me a place to put the code that sets the IsModified flag. Let's just run that and check that it worked.

And you can see that after I've set the Value property, the IsModified flag reflects that change as required. The obvious downside is that this is more verbose. It's not terrible. I can't complain about the fact that I've had to write the setter explicitly. The goal here was to customize that, but I've also got an explicitly implemented getter, which is effectively identical to what the compiler was generating, and I've also now got this field.

It's only a slight increase in clutter, but perhaps more concerning is the fact that it would be possible for other code in this class to use this field directly, bypassing my change detection. So the cliff wasn't a big one, it's a bit jarring, but this isn't a major problem. However, it comes up often enough that the C# team decided to support scenarios like this without forcing you to stop using automatic properties entirely.

In C# 14, I can leave the automatic get exactly as it is because I didn't actually wanna change that. Here I can customize just the setter. I can add this extra feature setting the IsModified flag. But how do I modify the value? Well, this is where I use the new syntax. Inside a get or set method, I can use the field keyword to refer to the compiler-generated field.

Let me just change the startup project and running that again, we get the required behavior. Comparing this to what we had to do before, you can see that this is a relatively small change. Before, I needed to declare my own field if I wanted to customize my property behavior, but now I can still get the compiler to generate that field for me.

Before, I had to write a custom getter, even though it was only the setter that I wanted to change. Now I can continue to use the compiler-generated getter. So this new feature has a fairly small impact, but what I prefer about the new code is that it removes clutter. I can see immediately that the getter does nothing out of the ordinary, so it's easy to see the one thing that makes this property slightly unusual.

The other benefit is I've not had to introduce a field. And while that's just one line of code, it's a line that doesn't sit all that well with some widely used .NET style guidelines that require fields to be declared in a separate part of the code from properties. Often the field and property could end up being quite distant, and when conceptually closely related code gets scattered across a file, it increases the work required to understand the code.

Arguably that's a flaw in the coding style guidelines, but for better or worse, it's a very common style in .NET that does provide benefits in some scenarios. Also, by using the compiler-generated field, I can be sure that the only code that modifies the field directly is this line here, and with the old approach, I'd need to search for other uses of the field to understand whether any code elsewhere in the class might be bypassing this change detection.

So in conclusion, C# 14 enables us to continue to enjoy the benefits of automatic properties, even when we move beyond their basic capabilities. So automatic properties have always given us a concise way to get basic property behavior, but now if we want to extend beyond that behavior, we can do so without having to fall off the cliff of support.

My name's Ian Griffiths. Thanks for listening.

Read the whole story
alvinashcraft
24 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Learn NestJS for Beginners

1 Share

NestJS is a progressive Node.js framework for building efficient and reliable server-side applications. It uses TypeScript by default and encourages clean, modular code with concepts including controllers, services, and dependency injection.

We just published a NestJS course on the freeCodeCamp.org YouTube channel that will help you harness it’s modular architecture, TypeScript support, and built-in tools to create clean, testable, code.

In this course, you'll explore controllers, services, modules, decorators, pipes, guards, and exception handling - all while building the profile feature for DevMatch, a dating app for developers.

You’ll implement profile creation, updates, and data retrieval while exploring the full lifecycle of a NestJS backend. By the end, you’ll have a solid foundation in NestJS fundamentals, plus the confidence to apply these skills to your own APIs and applications.

The course covers:

  • Understand NestJS fundamentals: modules, decorators, and structure.

  • Build controllers to handle GET, POST, PUT, and DELETE requests.

  • Connect controllers to services to manage application logic.

  • Implement validation and transformation with pipes.

  • Handle errors gracefully with exception filters.

  • Use guards to manage application security and access control.

  • Solve hands-on challenges that reinforce each concept.

Watch the full course on the freeCodeCamp.org YouTube channel (2-hour watch).



Read the whole story
alvinashcraft
25 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Learn R Programming from Harvard University

1 Share

Harvard University creates amazing beginner computer science courses.

We just released Harvard CS50’s introduction to programming using a language called R, a popular language for statistical computing and graphics in data science and other domains. Carter Zenke developed this course.

Learn to use RStudio, a popular integrated development environment (IDE). Learn to represent real-world data with vectors, matrices, arrays, lists, and data frames. Filter data with conditions, via which you can analyze subsets of data. Apply functions and loops, via which you can manipulate and summarize data sets. Write functions to modularize code and raise exceptions when something goes wrong. Tidy data with R’s tidyverse and create colorful visualizations with R’s grammar of graphics. By course’s end, learn to package, test, and share R code for others to use. Assignments inspired by real-world data sets.

Here are the sections in this course:

  • Introduction

  • Representing Data

  • Transforming Data

  • Applying Functions

  • Tidying Data

  • Visualizing Data

  • Testing Programs

  • Packaging Programs

Watch the full course on the freeCodeCamp.org YouTube channel (9-hour watch).



Read the whole story
alvinashcraft
25 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Podcast: GenAI Security: Defending Against Deepfakes and Automated Social Engineering

1 Share

In this episode, QCon AI New York 2025 Chair Wes Reisz speaks with Reken CEO and Google Trust & Safety founder Shuman Ghosemajumder about the erosion of digital trust. They explore how deepfakes and automated social engineering are scaling cybercrime and argues defenders must move beyond default trust, utilizing behavioral telemetry and game theory to counter attacks that simulate human behavior.

By Shuman Ghosemajumder
Read the whole story
alvinashcraft
25 minutes ago
reply
Pennsylvania, USA
Share this story
Delete

Enhanced security in NuGet for .NET 10

1 Share

Yes! .NET 10 is out and not only does it come with a new SDK and runtime version, but it is accompanied by a new NuGet version. With this version, Microsoft has significantly strengthened NuGet's security capabilities to help build more secure applications. These enhancements focus on improved vulnerability detection, automated package management, and better tooling for managing your dependency tree.

Let's explore what's new and how these features can help protect your projects.

Transitive dependency auditing

The change with probably the biggest impact is the NuGet Audit's default behavior. For projects targeting .NET 10 or higher, the NuGetAuditMode property now defaults to all instead of direct. This means that NuGet will automatically scan not just your direct package references, but also all transitive dependencies for known security vulnerabilities.

That’s good news as a a majority of vulnerabilities are often found in indirect dependencies. In a typical .NET project with around 50 total dependencies, you might have only 6-10 direct dependencies but 20-70 transitive dependencies. Previously, these transitive vulnerabilities could go unnoticed unless you explicitly opted in to scan them.

During dotnet restore, NuGet checks all packages against the GitHub Advisory Database for known CVEs (Common Vulnerabilities and Exposures) and GHSAs (GitHub Security Advisories). When a vulnerability is detected, you'll see warnings like:

warning NU1902: Package 'Example.Package' 5.0.0 has a known moderate severity vulnerability, https://github.com/advisories/GHSA-xxxx-xxxx-xxxx
Configuring Audit Behavior

If you need to adjust this behavior, you can configure it in your project file or in a separate Directory.Build.props file:

Vulnerability remediation

When you discover a vulnerability, follow these recommended steps:

  1. Try upgrading the top-level package first: Often, updating the direct dependency will pull in a fixed version of the transitive package.
  2. Upgrade intermediate packages: If updating the top-level package doesn't help, try upgrading packages in the middle of the dependency chain.
  3. Promote the transitive package: As a last resort, add an explicit PackageReference for the vulnerable transitive package at a fixed version.

The good news is that with .NET 10, you can simplify this process by executing  the dotnet package update --vulnerable command. This will update all vulnerable packages in a project to the first version without known vulnerabilities:

More information

Auditing package dependencies for security vulnerabilities

What's new in the SDK and tooling for .NET 10

Breaking change: 'dotnet restore' audits transitive packages - .NET | Microsoft Learn

Read the whole story
alvinashcraft
25 minutes ago
reply
Pennsylvania, USA
Share this story
Delete
Next Page of Stories