How to show “An app on your PC needs the following Windows feature.” dialog programmatically?

混江龙づ霸主 提交于 2019-12-06 08:59:48

问题


When I try to run .NET 3.5 applications on Windows 8.1 which has not .NET 3.5 Framework, Windows will show the "An app on your PC needs the following Windows feature. .NET Framework 3.5 (includes .NET 2.0 and .NET 3.0)" dialog automatically.

But I want to show this dialog programmatically. I think that the dialog is much more friendly than DISM command.

Any help would be appreciated.


回答1:


The dialogue you are searching for is provided by a tool called Fondue (Features on Demand User Experience Tool). To request .NET 3.5 you need to invoke it like this:

FONDUE.exe /enable-feature:NetFx3

Available features can be listed using DISM:

DISM.exe /Online /Get-Features

You can find additional details on Fondue invocation using FONDUE.exe /? or on TechNet.




回答2:


  1. Search the registry for .NET 3.5 using Microsoft's suggested code.
  2. Create a Windows Form program and show a MessageBox if the PC does not have .NET 3.5. example code

This is predicated on the PC having a .NET Framework installed. You can't check if the .NET Framework is installed using C#.




回答3:


It's impossible. But here I have 2 solutions.

  1. You can make a starter in C# or other programming laguage used to check the registry key of .NET Framework to determine which version has the user installed, or no .NET Framework installed.

  2. Using InnoSetup. InnoSetup allows you to write some scripts to check dependency on the user's computer. You should package your application to a setup application. Therefore, your application is no longer a portable software.



来源:https://stackoverflow.com/questions/29551954/how-to-show-an-app-on-your-pc-needs-the-following-windows-feature-dialog-prog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!