我们的安装应用程序提示输入用户名和密码,并使用此信息安装.NET服务。我们有一个Windows服务,它安装在
InstallUtil.exe
/username=auser
/password=password
/name=TestService
MyService.exe在我们的客户开始使用包含空格的强密码之前,这很好。这就变成了:
InstallUtil.exe
/username=auser
/password=password
with
spaces
/name=TestService
MyService.exe此调用失败,出现以下错误:
初始化安装时发生异常: System.IO.FileNotFoundException:无法加载文件或程序集的System.IO.FileNotFoundException或其依赖项之一。系统找不到指定的文件。
我们如何向InstallUtil.exe发送带有空格的密码?
发布于 2014-05-27 23:05:08
在没有参数的情况下运行InstallUtil.exe,您可以看到使用情况:
用途: InstallUtil /u \ /uninstalloption .汇编[选项[.]]大会]
在我提供的示例中,代码试图发送密码“带空格的密码”。这是以一种使安装程序认为密码是“密码”和程序集名称为"with“的方式放置到命令行中的。不存在名为"with“的文件。这导致了System.IO.FileNotFoundException。
答案是将引号放在密码(以及InstallUtil.exe的任何其他参数)周围:
InstallUtil.exe
/username="user name with spaces"
/password="password with spaces"
/name="Service Name With Spaces"
"Executable Name With Spaces.exe"发布于 2014-05-27 23:11:54
您可以将每个参数用双引号括起来:
installutil.exe "/username=user 1" "/password=pass word"https://stackoverflow.com/questions/23900326
复制相似问题