Using java, I would like some code that could get me the paths for: 1) Start Menu for Current User 2) Start Menu for All User
I need the answer for both WinXP and Win7. So hopefully there is a general answer that can get me both.
Using java, I would like some code that could get me the paths for: 1) Start Menu for Current User 2) Start Menu for All User
I need the answer for both WinXP and Win7. So hopefully there is a general answer that can get me both.
Another option is managing Start Menu items from vbs API.
I made a Java Wrapper for that.
Okay, I figured out a solution, but maybe someone else has a more eligant one.
I plan on doing something like "Runtime.getRuntime().exec(command);" and the command will be a "reg query" to query the following registry keys:
Current User can referenced by: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Start Menu
All users can be referenced by: HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Common Start Menu
These are the same for both Win7 and WinXP. If anyone else knows of a better solution, I'll be happy to look at it too.
You have no other choice but to write a DLL and call native Windows API:
SHGetFolderPath
(NULL, CSIDL_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, &szPathBuffer)
SHGetFolderPath(NULL, CSIDL_COMMON_PROGRAMS, NULL, SHGFP_TYPE_CURRENT, &szPathBuffer)
If you really need the root of Start menu, use
CSIDL_STARTMENU
andCSIDL_COMMON_STARTMENU
.The full list of known folders: CSIDL.
If you target Windows Vista and above, use
SHGetKnownFolderPath
function instead ofSHGetFolderPath
.You can use JNA library to call native Windows API without writing native code yourself but pure Java code.
i recently found this
In my program I used a simple
System.getProperty("user.home") + "/Start Menu/Programs"
This gave me the user's Start Menu folder.It worked on windows 7 and windows 10. I tried this because in order to get a user's desktop, all I had to do was call
System.getProperty("user.home") + "/Desktop"
. SO I figured that it might work for the Start Menu as well, and seemed to have worked fine. I can delete and write files to the Start Menu just like I can with the desktop. Whether this is the right way to do something like this or not, I have no idea. But I'm just sharing what worked for me.