Our install application prompts for a user name and password and installs a .NET service with this information. We have a Windows service that is installed using
InstallUtil.exe
/username=auser
/password=password
/name=TestService
MyService.exe
This works fine until our customers start using strong passwords containing spaces. Then this becomes:
InstallUtil.exe
/username=auser
/password=password
with
spaces
/name=TestService
MyService.exe
This call fails with the following error:
Exception occurred while initializing the installation: System.IO.FileNotFoundException: Could not load file or assembly 'file:///C:\Users\me[snip]\with' or one of its dependencies. The system cannot find the file specified.
How can we send a password with spaces to InstallUtil.exe?
Running InstallUtil.exe with no parameters, you can see the usage:
In the example I provided, the code tried to send the password "password with spaces". This was placed into the command line in a way that made the installer think the password is "password" and the assembly name is "with". No file named "with" existed. This caused the
System.IO.FileNotFoundException
.The answer is to put quotes around the password (and any other parameters to InstallUtil.exe):