How to get the list of items available in start menu using c#

Dineshkumar.S 446 Reputation points
2022-09-19T05:50:29.51+00:00

I'm creating windows application using c#, where i'm automating windows.

I'm trying to get the list of items in the start menu in windows 8.1. When we press only window key and we get some items on the start menu screen, i want to fetch these items only but not those which we get when we press "DownArrow" button on the bottom of the start menu screen.

Can anyone suggest me an method to check that ?

.NET CLI
.NET CLI
A cross-platform toolchain for developing, building, running, and publishing .NET applications.
322 questions
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,238 questions
0 comments No comments
{count} votes

Accepted answer
  1. Jack J Jun 24,286 Reputation points Microsoft Vendor
    2022-09-20T02:35:08.113+00:00

    @Dineshkumar.S , Welcome to Microsoft Q&A, based on my test, It seems that it is hard to get all items in start menu at once.

    Based on my search, most of items is placed in the path C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs.

    Please refer to the following steps:

    First, Please get the file name with extension name .lnk.

        string path = "C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs";  
        List<string> list = new List<string>();  
        var files=Directory.GetFiles(path,"*.lnk").Select(i=>Path.GetFileNameWithoutExtension(i));  
        list.AddRange(files);  
    

    Second, Please get the folder name.

        var dir=Directory.GetDirectories(path).Select(i=>new DirectoryInfo(i).Name);  
        list.AddRange(dir.ToArray());  
    

    Third, We need to add the name about system tool(e.g. Calculator) to the list manually, because there are not in the same location.

     list.Add("Calculator ");  
     .....  
    

    Hope my code could help you.

    Best Regards,
    Jack


    If the answer is the right solution, please click "Accept Answer" and 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 additional answers

Sort by: Most helpful