Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to get and fetch the items in the Start menu and run any program from the menu

What I have tried:

string s = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);
Posted
Updated 24-Dec-17 4:23am
Comments
Richard MacCutchan 24-Dec-17 9:58am    
OK, and what is your problem?
Khaled_Taha 24-Dec-17 10:50am    
I want to get and fetch the items in the Start menu and run any program from the menu

1 solution

Start by using the code you have, but you now need to read all the files:
string s = Environment.GetFolderPath(Environment.SpecialFolder.CommonStartMenu);
string[] files = Directory.GetFiles(s, "*.lnk", SearchOption.AllDirectories);
int i = the index of the app you want;
Process.Start(files[i]);
Do note that .LNK files are not just .EXEs - any valid target (such as a readme.txt) can be in a .LNK file

To restrict it to just EXES, you need to inspect the LNK file content yourself.
 
Share this answer
 
Comments
Khaled_Taha 24-Dec-17 10:50am    
OK,Thanks

but first How to read all the files

and second How to get of the *.lnk
OriginalGriff 24-Dec-17 11:21am    
Did you read the code sample, at all?
Khaled_Taha 24-Dec-17 11:28am    
yes am read
OriginalGriff 24-Dec-17 11:38am    
And which part of it is giving you problems?
ThatCodingGuy 21-Jul-21 7:54am    
Hi, just wanted to thank you for this solution.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900