Unable to run an a created application on Windows 10 Enterprise

Davey362 1 Reputation point
2021-03-02T20:13:40.34+00:00

I have been working on a C# application recently that would be used on a Windows 10 Enterprise system. The issue is that when a button is pressed on the application, it should open the On-screen Keyboard but when I do press it, nothing seems to happen. I have tested this application on windows 7 devices and a windows 10 Pro device and it works as intended on both. To make for easier testing, I wrote a small application that would simply send the start process command for the OSK:
Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = "osk" });

The results were the same as the application except for the command prompt window opens for a second and then disappears when used on Win10 Enterprise . I can run the command in the command prompt and it works on all systems so it isn't that OSK doesn't work in the testing environment. In addition, I also tried the tests above with joy.cpl instead of OSK and the results were the same. Any advice would be appreciated.

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,627 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Timon Yang-MSFT 9,586 Reputation points
    2021-03-03T06:53:20.763+00:00

    It seems that osk.exe can only run on x64.

    When I use AnyCPU, an exception occurs:
    73577-capture.png

    When I switch the PlatformTarget to x64, everything works fine.

    I am using Windows 10 Enterprise, version 2004.


    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Castorix31 83,106 Reputation points
    2021-03-03T07:27:06.983+00:00

    Not sure if it is the Wow64 redirection problem, because you should get an exception...

    You can check if it is that with :

                bool bWow64 = false;
                IsWow64Process(Process.GetCurrentProcess().Handle, out bWow64);
                if (bWow64)
                {
                    IntPtr OldValue = IntPtr.Zero;
                    bool bRet = Wow64DisableWow64FsRedirection(out OldValue);
                }
                Process.Start(new ProcessStartInfo { UseShellExecute = true, FileName = "osk" });
    

    Declarations :

        [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        private static extern bool IsWow64Process(IntPtr hProcess, out bool Wow64Process);
    
        [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
        private static extern bool Wow64DisableWow64FsRedirection(out IntPtr OldValue);