Tuesday, December 3, 2024

Configure Console Application as Windows Service

 To configure a console application as a Windows Service, you'll need to follow several steps, which typically involve writing a service wrapper around your console application. You can then use sc command or PowerShell to install and manage the service. Below are the steps to configure a console application as a Windows service.


Method 1: Using sc (Service Control) Command

  1. Open Command Prompt as Administrator:

    • Press Win + X and select Command Prompt (Admin) or Windows PowerShell (Admin).
  2. Install the Service: Use the following command to install your service:

    • Replace "C:\Path\To\Your\Executable.exe" with the actual path to the compiled .exe file of your service.
    • Ensure there is a space after binPath=, otherwise, the command might fail.


    sc create "MyService" binPath= "C:\Path\To\Your\Executable.exe"
  3. Start the Service: Once the service is installed, you can start it using:

    sc start "MyService"
  4. Stop the Service: To stop the service, use:

    sc stop "MyService"
  5. Delete the Service: If you no longer need the service, you can delete it with:

    sc delete "MyService"

Method 2: Using PowerShell to Install the Service

If you prefer using PowerShell, follow these steps:

  1. Open PowerShell as Administrator:

    • Press Win + X and select Windows PowerShell (Admin).
  2. Install the Service: You can install your service using New-Service cmdlet in PowerShell:

    New-Service -Name "MyService" -Binary "C:\Path\To\Your\Executable.exe" -StartupType Automatic
  3. Start the Service:

    Start-Service "MyService"
  4. Stop the Service:

    Stop-Service "MyService"
  5. Remove the Service:

    Remove-Service "MyService"

Friday, July 3, 2020

Hyper-V Linux Resolution Update

When we Install Linux OS on hyper-V on Windows 10 system, we having screen resolution issue on virtual machine, here below are commands to change resolution in virtual machine.
Open your terminal Window.
Execute below command to edit file.
sudoedit /etc/default/grub
Below File will be open to Edit.
In this file make Yellow highlighted change in the line in Red and save changes and
close file

You can use your specific resolution which you want instead of 1920x1080, it’s not necessary to use the same
Then back to terminal and execute below command
sudo update-grub
Execute below command to restart the system
sudo reboot
Enjoy the updated resolution J

Configure Console Application as Windows Service

  To configure a  console application  as a  Windows Service , you'll need to follow several steps, which typically involve writing a se...