Click here to Skip to main content
15,606,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
To write a C# code to be able to change compatibility mode and reduced color mode of .exe files utilizing batch files.

I have my code to write simple batch files using C# and to run it. It's running well ! Only need to know, how to get the modifications in Compatibility mode and Reduced color modes. Thanks in advance !!

What I have tried:

C#
namespace RunBatchFile
{
     class Program 
     {
         static void Main(string[] args)
 { 
RunCalculator(); 
 }

    public static void RunCalculator()
    {

        //this is the path the document or in our case batch file will be placed
        string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

        //this is the path process.start usues
        string path1 = docPath + "\\Test.bat";

        string[] lines =
        {
        "@echo off",
        //"REG ADD HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\WindowsNT\\CurrentVersion\\AppCompatFlags
        //\\Layers",
        "calc.exe"
        };

        //this writes the string to the file
        using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, "test.bat")))
        {
            //This writes the file line by line
            foreach (string line in lines)
            outputFile.WriteLine(line);
        }
        System.Diagnostics.Process.Start(path1);

    }
}
}
Posted
Updated 9-Feb-21 8:07am
v2

1 solution

See answer here: windows 10 - setting compatibility mode via CMD - Super User[^]

If you use HKLM you need to run your program as administrator, this is not needed for the current user HKCU.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900