How to force Compatibility-mode for Windows 8 when ClickOnce application is executed

462 Views Asked by At

I have a problem with a ClickOnce application I develop: on certain builds of Windows 10, the ClickOnce client is downloaded, executed by the .net framework but nothing is displayed.

It seems that if I go in the task manager, select the process, open the details, select the checkbox "Run this program in compatibility mode for Windows 8", it works fine.

Settings of proces enabling compatibility mode

As I don't want every client to perform this manipulation, I am looking for a way to force the ClickOnce client to execute with this compatibility mode for Windows 8 when it is started.

I checked the very little documentation, and changed the manifest of the application as this:

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
  <!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
  <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />
</application>

I tested again, but the ClickOnce client is not started with the proper compatibility mode.

Is there a way to achieve what I want to do?

Thanks!

1

There are 1 best solutions below

0
Joel On

Someone from the Microsoft team supported me very efficiently on social.msdn, so I will report here the solution:

We need to change the registry to set a key=value, where - key is the path of the executable - value is "WIN8RTM".

In the clickonce application, before I start anything, I call the following function:

void ForceWin8RTM() {
try {
    RegistryKey^ key = Registry::CurrentUser->OpenSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers", true);//Open the registry subkey
    System::String^ EXEName = System::Reflection::Assembly::GetExecutingAssembly()->Location;

    //If the item does not exist, create the sub-item 
    if (key == nullptr) 
    {
        key = Registry::CurrentUser->CreateSubKey("SoftWare\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers");            
    }
    //If the value does not exist, set the value and restart the program to apply the setting
    if (key->GetValue(EXEName) == "" || key->GetValue(EXEName) == nullptr)
    {
        key->SetValue(EXEName, "WIN8RTM");
        Application::Restart();
    }
} catch(Exception^ e) {
}

}

Here is the link of the thread on msdn : https://social.msdn.microsoft.com/Forums/en-US/056c7bf1-797f-4af7-83e2-d88b979e58a6/how-to-force-compatibilitymode-for-windows-8-whenclickonce-application-is-executed?forum=winformssetup