Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to resolve "'installutil' is not recognized as an internal or external command, operable program or batch file."?

Just tried to run an application via the following:

enter image description here

I have browsed to the directory with an app WindowsService1.exe in it, then tried the command Installutil WindowsService1.exe but got the following error...

enter image description here

As VS has only been installed for a day or two I'm worried that something may be wrong with that install as it should recognise installutil.

Are there some basic diagnostics I can perform to ensure that VS Command Prompt is finding all the programs that it should ?

EDIT

If i run PATH in the command prompt I see the following:

enter image description here

like image 398
whytheq Avatar asked Oct 03 '12 07:10

whytheq


People also ask

How do you fix is not recognized as an internal or external command operable program or batch file?

You can resolve this issue in three ways: First, use the full path of the executable file to launch the program. Second, add the program path to Windows environment variables. Finally, move the files to the System32 folder.

Where is InstallUtil exe located?

The InstallUtil binary may also be digitally signed by Microsoft and located in the . NET directories on a Windows system: C:\Windows\Microsoft.NET\Framework\v \InstallUtil.exe and C:\Windows\Microsoft.NET\Framework64\v \InstallUtil.exe .

What is InstallUtil exe?

The Installer tool is a command-line utility that allows you to install and uninstall server resources by executing the installer components in specified assemblies. This tool works in conjunction with classes in the System. Configuration. Install namespace. This tool is automatically installed with Visual Studio.


2 Answers

This is a tiny bit off-topic but I've stopped using InstallUtil to install my services. It's is really easy to just add it to the service itself. Add a reference to System.Configuration.Install (not available in the Client Profile editions if I remember right) and then update your Main()-function in Program.cs like this.

static void Main(string[] args) {     if (Environment.UserInteractive) {         var parameter = string.Concat(args);         switch (parameter) {             case "--install":                 ManagedInstallerClass.InstallHelper(new[] { Assembly.GetExecutingAssembly().Location });                 break;             case "--uninstall":                 ManagedInstallerClass.InstallHelper(new[] { "/u", Assembly.GetExecutingAssembly().Location });                 break;         }     } else {         ServiceBase[] servicesToRun = {              new Service1()          };         ServiceBase.Run(servicesToRun);     } } 

Then you can just call WindowsService1.exe with the --install argument and it will install the service and you can forget about InstallUtil.exe.

like image 195
Karl-Johan Sjögren Avatar answered Oct 05 '22 21:10

Karl-Johan Sjögren


This is what I have done to make it go away:

  1. Found where installutil resides on my PC. In my case it was C:\Windows\Microsoft.NET\Framework\v4.0.30319

  2. Opened a command prompt as an Administrator and changed current directory to above: 'cd C:\Windows\Microsoft.NET\Framework\v4.0.30319'

  3. Then entered: 'installutil C:\MyProgramName.exe'

Interestingly, prior to above solution I tried different options, among them adding C:\Windows\Microsoft.NET\Framework\v4.0.30319 to the System Path variable, but it still could not find it.

Wish you all smooth installation.

like image 39
user3085805 Avatar answered Oct 05 '22 22:10

user3085805