Launch the Service Controller App from C# WinUI 3

Hemanth B 886 Reputation points
2022-05-26T14:29:36.977+00:00

How do I launch the Service Controller App that is part of the MMC from C# WinUI 3 app?

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
711 questions
0 comments No comments
{count} vote

Accepted answer
  1. Junjie Zhu - MSFT 13,971 Reputation points Microsoft Vendor
    2022-05-27T03:10:08.673+00:00

    Hello,
    Welcome to Microsoft Q&A!

    The Service Controller App can be opened by calling the cmd Process(System.Diagnostics) in C#.

    Process CmdProcess = new Process();  
    CmdProcess.StartInfo.FileName = "cmd.exe";  
    
    CmdProcess.StartInfo.CreateNoWindow = true;          
    CmdProcess.StartInfo.UseShellExecute = false;        
    CmdProcess.StartInfo.RedirectStandardInput = true;     
    CmdProcess.StartInfo.RedirectStandardOutput = true;      
    CmdProcess.StartInfo.RedirectStandardError = true;    
    
    CmdProcess.StartInfo.Arguments = "/c " + "services.msc"; //“/C”Indicates to exit immediately after executing the command    
    CmdProcess.Start();  
    CmdProcess.StandardOutput.ReadToEnd();//get return value     
    CmdProcess.WaitForExit();//Wait for the program to finish executing and exit the process  
    CmdProcess.Close();//END  
    

    205984-gif-2022-5-27-11-12-39.gif

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful