In c# can I write code to run a Windows 11 shortcut link programmatically?

Paddy Patterson 21 Reputation points

For a Windows 10 shortcut lnk, I could use Shell32.ShellLinkObject.

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.
7,514 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
4,044 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Castorix31 68,491 Reputation points

    I don't have Windows 11, but it would be weird if a simple Process.Start did not work anymore.
    A test on Windows 10 with a TestNotepadLink.lnk to Notepad on Desktop

                string sDestPath = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                string sLink = "TestNotepadLink.lnk";
                string sShortcut = sDestPath + "\\" + sLink;
                using (Process p = new Process())
                    p.StartInfo.FileName = sShortcut;

  2. Jack J Jun 21,741 Reputation points Microsoft Vendor

    @Paddy Patterson , based on my research, I find a new method to run a shortcut link in windows 11.

    Here is a code example you could refer to.

     internal class Program  
            public enum ShowWindowCommands : int  
                SW_HIDE = 0,  
                SW_SHOWNORMAL = 1,      
                SW_NORMAL = 1,  
                SW_SHOWMINIMIZED = 2,  
                SW_SHOWMAXIMIZED = 3,  
                SW_MAXIMIZE = 3,  
                SW_SHOWNOACTIVATE = 4,  
                SW_SHOW = 5,  
                SW_MINIMIZE = 6,  
                SW_SHOWMINNOACTIVE = 7,  
                SW_SHOWNA = 8,  
                SW_RESTORE = 9,  
                SW_SHOWDEFAULT = 10,  
                SW_MAX = 10  
            public static extern IntPtr ShellExecute(  
                IntPtr hwnd,  
                string lpszOp,  
                string lpszFile,  
                string lpszParams,  
                string lpszDir,  
                ShowWindowCommands FsShowCmd  
            static void Main(string[] args)  
                string sLink = "1 - Shortcut";  
                ShellExecute(IntPtr.Zero, "open", sLink, null, null, ShowWindowCommands.SW_SHOWMAXIMIZED);  

    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.