Process.Start not working on Windows 11 when running under admin privileges (.netcore)

Tomer.Z 96 Reputation points
2022-02-02T11:49:06.273+00:00

First time I've experiencing the following behavior:
I have a desktop app (Windows, net core 3.1, netstandard2.1).
Long story short, the app downloads a byte[], saves it to .exe and executes it.

When my app runs as a normal user i am able to execute Process.start to that executable (i am also using this method to self-restart to add firewall permissions).
When my app is running under admin privileges Process.start doesn't work.

This is happening both under VS debugger and shell execution and also with and without "runas", it simply doesn't work.
No exception, not permissions window, nothing.

Am i missing something here, is it forbidden for an admin to execute Process.start?
I upgraded to Win11 from Win10 so i am unable to tell if it happen before (on old OS).
Is it a bug in Win11? netcore?
Thank you.

edit:
This is the method i am using to launch an executable.

public void RunExecutable(string filePath, string args)
        {
            try
            {
                ProcessStartInfo startInfo;

                startInfo = new ProcessStartInfo(filePath)
                {
                    UseShellExecute = true,
                    Verb = "runas",
                    WindowStyle = ProcessWindowStyle.Normal,
                    FileName = filePath,
                    CreateNoWindow = false
                };
                startInfo.WorkingDirectory = Path.GetDirectoryName(filePath);
                Process.Start(startInfo);
            }
            catch (Exception ex)
            {
                //User canceled the prompt
            }
        }
.NET Runtime
.NET Runtime
.NET: Microsoft Technologies based on the .NET software framework.Runtime: An environment required to run apps that aren't compiled to machine language.
1,141 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,988 questions
{count} votes

1 answer

Sort by: Most helpful
  1. EckiS 831 Reputation points
    2022-02-05T05:12:05.07+00:00

    You should log the exception instead of simply ignoring it.
    This will probably give you information on what went wrong.

    0 comments No comments