question

DineshkumarS-4414 avatar image
0 Votes"
DineshkumarS-4414 asked DineshkumarS-4414 commented

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

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 ?

dotnet-csharpdotnet-cli
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

JackJJun-MSFT avatar image
0 Votes"
JackJJun-MSFT answered DineshkumarS-4414 commented

@DineshkumarS-4414, 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.

· 5
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hey Jack thanks for the suggestion I will check with the code and let you know and thanks for the help once again

0 Votes 0 ·

Don't mark as answer if you did not check it, and this answer is not right and does not answer to your question :
" 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."

0 Votes 0 ·

Sorry for that and I have found another one approach for that I will share you the details
for the current user
string startmenu = Environment.GetFolderPath(Environment.SpecialFolder.StartMenu);
IEnumerable<string> files = Directory.GetFiles(startmenu, ".", SearchOption.AllDirectories).Select(x => x.Split('\\').Last().Split('.').First());

     foreach (var file in files)
     {
         Console.WriteLine(file);
     }

     Console.ReadKey();


// this for the all users
string startmenu = Environment.GetFolderPath(Environment.SpecialFolder. CommonStartMenu
);
IEnumerable<string> files = Directory.GetFiles(startmenu, ".", SearchOption.AllDirectories).Select(x => x.Split('\\').Last().Split('.').First());

     foreach (var file in files)
     {
         Console.WriteLine(file);
     }

     Console.ReadKey();



0 Votes 0 ·
Show more comments

Yes I am also noticed that and I jus want the items in the start menu so I used this and If you find any approach t0 filter it out Please do share me the approach. Thanks in advance.

0 Votes 0 ·