Skip to content

5000+ Great Articles

Best Articles & Essays: Interesting Articles to Read Online

  • passport renewal fee in us embassy

    passport renewal fee in us.us passport renewal fee in pakistan 2019.urgent u.s. passports in pakistan. American Citizen Services is closed to the publ

  • Is Best iPhone Recovery Software – iMyFone Fixppo? Tools Review
  • ACEFAST Crystal (2) T8 Earbuds Review Gadgets
  • Best printing calculator paper rolls 2020

    Best printing calculator paper rolls 2020. 1 - LOSRECAL Thermal Receipt Paper Rolls, 2 1/4" x 50' x 10 Rolls, POS Thermal Paper Rolls fit Credit Car

  • How To Use Flash Fill In Excel Office Tips
  • Best Digital Camera Settings For Sunset Photos How-To
  • Make a Web App Run Like a Desktop App How-To
  • How to Fix Bootloop on Android Smartphone How-To

What Do I Need to Create a Windows Service?

Posted on June 22, 2023June 22, 2023 By blog_786 1 Comment on What Do I Need to Create a Windows Service?

What Do I Need to Create a Windows Service?.

Sometimes you need an application or script to keep working regardless of whether you are logged into your computer or not. Maybe it’s a PowerShell script for monitoring ports, or a web server that hosts a page on your home network.

The point is, if you want a process, script or program to run while the computer is on, you need to create a Windows service.

What Do I Need to Create a Windows Service?

What Do I Need to Create a Windows Service?

To create a Windows service in Windows 10, several prerequisites must be met:

  • Administrator access on the computer.
  • Something to run as a service (PowerShell script, program, etc.)
  • Non-Sucking Service Manager (NSSM) installed.

What Is the Non-Sucking Service Manager?

Yes, one cannot give such a name without explanation. Of course, the name is unfortunate, but it is accurate. The No Suction Services Manager (NSSM) is perhaps the simplest way to create a Windows service that is both highly reliable and customizable. In addition, it is free and open source software (OSS).

What Do I Need to Create a Windows Service?

NSSM can be used through the Windows command line or graphical user interface (GUI). This means that anyone can use it. NSSM can be used on any version of Windows starting from Windows 2000 inclusive. There are 32-bit and 64-bit versions. If you are using a 64-bit computer, please try this version first. If doesn’t work, go back to 32-bit.

You can download NSSM from the website, clone NSSM from Git, or install NSSM using Chocolatey. Chocolatey is a package manager for Windows. The installation methods depend on the route you choose. See NSSM Instructions. In our example, we download from the NSSM website and install it to C: WINDOWS system32.

– /

Create a Windows Service With NSSM

In this example, we will create a service from a PowerShell script to log the average CPU utilization.

  1. Copy and save this script as log-CPULoadPercentage.ps1 in a location that is unlikely to be accessible to anyone else. Try to create a C: / Scripts directory and save it there. Also, create a folder in your scripts called Logs. Note that the path to the script is C: /Scripts/log-CPULoadPercentage.ps1. You will need this later.

Note. All lines below followed by # are comments and do not affect the script.

CLS # Optional. I like to use this to clear the terminal when testing. # Make sure you have a Logs folder in the same directory as this script. # The log will keep records. Start-Transcript -Path “$ PSScriptRoot Logs log-CPULoadPercentage – $ (get-date -f yyyy-MM-dd) .txt” -Append # While the loop continues to run until manually stopped While ($ True) {#Creates a timestamp to see when the measurement was taken $ timeStamp = get-date -f yyyy-MM-h: mm: ss # Gets the average load percentage at this time, then waits 5 seconds to do it again … $ cpuLoadPercent = Get-CimInstance win32_processor | Measure-Object -Property LoadPercentage -Average | Select-Object Average; Start-Sleep -Seconds 5 # Isolates only the mean so that there is no strange line @ {Average = 13} $ cpuLoadPercent = $ cpuLoadPercent.Average # prints the results to the screen or, in this case, to the log Write-Host “$ timeStamp CPU Load Percentage $ cpuLoadPercent “} Stop-Transcript

  1. This can be done either from the Windows Command Prompt or PowerShell. Open it as administrator.
  2. Enter the nssm install logCPUAvg command and run it. The NSSM Service Installer window opens.

What Do I Need to Create a Windows Service?

  1. Click the ellipsis button next to the Path: field and navigate to powershell.exe, which is usually located in the C: Windows System32 folder. Select powershell.exe. The “Path:” and “Launch directory:” fields will be filled in automatically.

What Do I Need to Create a Windows Service?

  1. Enter the following in the Arguments: field: -ExecutionPolicy Bypass -NoProfile -File “C: PathToScript get-Script.ps1” where the last part is the path to your PowerShell. script and script name.

What Do I Need to Create a Windows Service?

  1. Click the Details tab. Enter what you want the service to appear in the Windows Service Manager in the Display Name: field. Then enter what it does in the Description: field. Startup type: can be set to automatic, automatic (delayed start), manual or disabled. Automatic mode is suitable for this exercise.

What Do I Need to Create a Windows Service?

  1. Select the Login tab. Select the radio button “This account:” and enter the account and password under which the service will run. You will need to select an account under which the service will run. Ideally, you should have a Windows account created just to run this service. This account’s permissions should only be limited to what the service needs to do. You can choose the Local System account, but this is not recommended for security reasons.

What Do I Need to Create a Windows Service?

There are several other tabs that you can use to configure the service. The defaults on these tabs are sufficient for this exercise. Click the Install Service button.

  1. After installing the service, you will see that the “logCPUAvg” service has been successfully installed! window. Select OK to close it. This completes the installation.

What Do I Need to Create a Windows Service?

  1. Open Windows Service Manager and verify that the service is present.

What Do I Need to Create a Windows Service?

  1. Start the service to make sure it will work.

What Do I Need to Create a Windows Service?

  1. To make sure this service is running, use Explorer to navigate to the location where you want to save the log and check if it exists.

What Do I Need to Create a Windows Service?

nssm-check-log.png

Removing a Windows Service With NSSM

You may no longer need to monitor your CPU usage, so you want to get rid of this service. Fortunately, NSSM makes this easy.

  1. In Windows Service Manager, stop the service. Do this by selecting the CPU Average Log Service and then either clicking the square stop button in the toolbar or the Stop Service link on the left.

What Do I Need to Create a Windows Service?

  1. Open a Windows Command Prompt or PowerShell as administrator.
  2. Enter the nssm remove logCPUAvg command and run the command.

What Do I Need to Create a Windows Service?

  1. NSSM will ask you for confirmation. Select “Yes”.

What Do I Need to Create a Windows Service?

  1. After removing the service, you will see that the “logCPUAvg” service has been removed successfully! The confirmation. Click OK and you’re done.

What Do I Need to Create a Windows Service?

That’s all. It is recommended that you check the service manager to make sure the service is no longer there. If you still see the service, you may need to refresh your screen and it should be gone.

Services are a great way to run applications or scripts that need to run constantly, reboot if they crash, or require privileges other than the current user. If you don’t need your application or script to perform all of these tasks, consider using a scheduled task.

–

What Do I Need to Create a Windows Service?

Share this:

  • Twitter
  • Facebook
Windows 10 Tags:Create a Windows Service With NSSM, Removing a Windows Service With NSSM, What Do I Need to Create a Windows Service?, What Is the Non Sucking Service Manager?

Post navigation

Previous Post: How to fix a fatal Javascript Discord error
Next Post: The color combination in photoshop like change

Related Posts

  • How to Clear the Clipboard in Windows 10 Windows 10
  • What is hiberfil.sys? Windows 10
  • What Is Yourphone.Exe in Windows 10 (And Should You Stop It) Windows 10
  • What is COM Surrogate in Windows 10 and Is It a Virus? Windows 10
  • Change Default Search Provider in Microsoft Edge to Google Windows 10
  • Best fixing unexpected BSOD kernel mode trap Windows 10

Comment (1) on “What Do I Need to Create a Windows Service?”

  1. Pingback: 10 Website Monitoring Service to Know When Your Site Goes Down

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Archives

  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • March 2021
  • October 2020
  • September 2020
  • August 2020
  • July 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • December 2019
  • July 2019
  • May 2019
  • April 2019
  • January 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018

Categories

  • AI Tools & Guides
  • Amazon Web Services
  • Apple Watch
  • Computer Tips
  • Cool Websites
  • Featured Posts
  • Free Software Downloads
  • Gadgets
  • Gaming
  • General Software
  • Google Software/Tips
  • Hardware
  • Help Desk
  • How-To
  • iOS
  • iPad
  • iPhone
  • islamic Books
  • Linux
  • Linux Tips
  • Mac OS X
  • macOS
  • MS Office Tips
  • Networking
  • Office Tips
  • OS X
  • Product Reviews
  • Reviews
  • Safari
  • Smart Home
  • Smartphones
  • Software Reviews
  • technology
  • text
  • Tools Review
  • Troubleshooting
  • Tutorials
  • Uncategorized
  • Urdu Books PDF
  • Web Site Tips
  • Windows
  • Windows 10
  • Windows 7
  • Windows XP Tips
  • Wordpress
  • 10 Things to Check Before Publishing a YouTube Video
  • A Simple Trick to Get 50% Discount on Audible for Three Months
  • How to reset your SIM card
  • This Simple Trick Lets You Play YouTube in the Background on iOS
  • How to go Back to the old YouTube Layout (2013)
DMCA.com Protection Status

Recent Posts

  • 10 Things to Check Before Publishing a YouTube Video
  • MailTag: Real-time Email Tracking, Made Easy
  • Pokemon Sleep: what is it and how to play
  • How to Respond to Messages on Instagram (Mobile and PC)
  • How to reset your SIM card

Recent Comments

  1. This Simple Trick Lets You Play YouTube in the Background on iOS on YouTube Not Working? Here Are Quick Fixes To Try
  2. How to Bypass Chromecast DNS and Circumvent Geo Blocking on 5 Cool Websites to Find Good Movies and TV Shows on Netflix
  3. 5 Cool Websites to Find Good Movies and TV Shows on Netflix on check netflix video quality internet explorer
  4. SmartDNS vs VPN “What’s the Difference?” on How to Watch Apple TV on Roku
  5. How to go Back to the old YouTube Layout (2013) on 10 Things to Check Before Publishing a YouTube Video
  • How To Allow Users To Self Assign Their Roles On Discord Server How-To
  • How to Adjust the Backlight on 2019 NVIDIA Shield TV Remote? How-To
  • How to Screen Share on Skype Mobile And Desktop How-To
  • The Easiest Way to Find & Load Subtitle (SRT) Files with Video Computer Tips
  • How To Install or Uninstall Safari Extensions on Mac , iPad and iPhone iPad
  • Google Analytics User Research Methods to Boost Website Traffic Google Software/Tips
  • How To Manually Set Up WordPress On a Domain Wordpress
  • OTT Explains : Is Facebook Listening To Me Through My Smartphone? Smartphones

Copyright © 2023 How To Blog.

Powered by PressBook News WordPress theme

Go to mobile version