Tuesday, March 16, 2021

Install and uninstall Windows services using InstallUtil.exe utility

 Install using InstallUtil.exe utility
  1. From the Start menu, select the Visual Studio <version> directory, then select Developer Command Prompt for VS <version>.

    The Developer Command Prompt for Visual Studio appears.

  2. Access the directory where your project's compiled executable file is located.

  3. Run InstallUtil.exe from the command prompt with your project's executable as a parameter:

         installutil <yourproject>.exe

 you’re using the Developer Command Prompt for Visual Studio, InstallUtil.exe should be on the system path. Otherwise, you can add it to the path, or use the fully qualified path to invoke it. This tool is installed with the .NET Framework in %WINDIR%\Microsoft.NET\Framework[64]\<framework_version>.

For example:

  • For the 32-bit version of the .NET Framework 4 or 4.5 and later, if your Windows installation directory is C:\Windows, the default path is C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe.
  • For the 64-bit version of the .NET Framework 4 or 4.5 and later, the default path is C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe.

Uninstall using InstallUtil.exe utility

1.    From the Start menu, select the Visual Studio <version> directory, then select Developer Command Prompt for VS <version>.

The Developer Command Prompt for Visual Studio appears.

2.    Run InstallUtil.exe from the command prompt with your project's output as a parameter:

installutil /u <yourproject>.exe

3.    After the executable for a service is deleted, the service might still be present in the registry. If that's the case, use the command sc delete to remove the entry for the service from the registry.

 


No comments: