ClickOnce 安装完成后如何避免运行应用程序?
我希望 setup.exe 仅执行设置(似乎是很自然的要求),以便用户稍后可以选择自己运行该应用程序。我尝试在 Visual Studio 的发布选项中“阻止通过 URL 激活应用程序”,但这似乎不起作用。 MageUI 中还有一个特定选项可以避免运行应用程序,但这似乎也不起作用。
I want setup.exe to do only the setup (seems like a natural thing to ask for), so that the user can later choose to run the application themselves. I tried "Block application from being activated via a URL" in publish options in Visual Studio, but that did not seem to work. There is also a specific option in MageUI to avoid running the application, but that also did not seem to work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想使用 Visual Studio 为您生成的 setup.exe 文件,我认为没有任何方法可以阻止它启动您的应用程序。大多数人都希望它能够启动。我想在您的应用程序代码中,您可以尝试检测它何时第一次运行并简单地终止它,但这对我来说似乎很不稳定。
您甚至不必使用 VS 生成的 setup.exe。你有多少先决条件?当您有很多先决条件时,它非常方便,但如果您只需要 .NET Framework,则可以跳过生成的引导程序,只需为它们提供下载链接。
更多笔记。 “阻止通过 URL 激活应用程序”对您不起作用。这仅意味着用户必须使用开始菜单快捷方式来运行应用程序,而不是在浏览器中输入 URL。另外,我并不完全确定,但我认为 MageUI 选项仅在您首次从浏览器而不是引导程序安装应用程序时才有效。不过,这一点可能是错误的。
编辑
我偶然发现了这个答案,安装 ClickOnce 而不运行。接受的答案显示了我的第一个建议的快速简便的实现 - 如果这是第一次运行该应用程序,则退出该应用程序。
If you want to use the setup.exe file that Visual Studio generates for you, I don't think there's any way to stop it from launching your app. Most people want it to launch. I suppose in your application code you could try to detect when it was run for the first time and simply kill it, but that seems pretty flaky to me.
You don't have to even use the setup.exe that VS generates. How many prerequisites do you have? It's very handy when you have a lot of prereqs, but if you just need the .NET Framework, you could skip the generated bootstrapper and just give them a link to the download.
Couple more notes. The "Block application from being activated via a URL" won't work for you. This just means that the user has to use the start menu shortcut to run the app rather than typing the url in a browser. Also, I'm not completely sure, but I think the MageUI option only works if you install your app for the first time from a browser and not the bootstrapper. Could be wrong on that one though.
Edit
I randomly stumbled across this answer, Install ClickOnce Without Running. The accepted answer shows a quick and easy implementation of my first suggestion - quitting the app if it's the first time it has been run.
在“签名”选项卡上的 Visual Studio 项目属性中,单击“选项...”,然后在“清单”选项卡中选中“阻止通过 URL 激活应用程序”。
发布并检查。它应该有效。
资源链接: http://msdn.microsoft.com/en-us/library /ms404268.aspx
In Visual Studio project properties on Signing tab click on Options... and in Manifests tab check the "Block application from being activated via a URL".
publish and check. It should work.
link to resource: http://msdn.microsoft.com/en-us/library/ms404268.aspx