get start menu path

Blitz3D Forums/Blitz3D Programming/get start menu path

jfk EO-11110(Posted 2006) [#1]
Is there a way to get the start menu path from windows? Preferable the all users start menu. I know it may be c:/documents and settings/all users/start menu. The point is, on win9x this may differ, and there are also language diffrences (eg. "Startmenü" etc.).

There are commands for the system folder, the windows folder, I'm sure there must be one for this.


jfk EO-11110(Posted 2006) [#2]
Uh, I just used to read unless I am using NET there is no simple function for this. So I may check several paths and decide to use an existing folder.

Could some people with german windows XP or win200 help me?

How is the path, is it:
c:/dokumente und einstellungen/all users/startmenü/

??

thanks.


b32(Posted 2006) [#3]
There seems to be a command SHGetSpecialFolderPath in shell32.dll. Not sure if it is .net related. I was able to use it to retreive the startmenu name using this code:



jfk EO-11110(Posted 2006) [#4]
Thanks b32, your help is highly appreciated. I think in the decls it should be hwndOwner%, since you hand over an int in blitz. Anyway it didn't work. I then tested other values for the folder parameter (yours was $16, that returned nothing). I used it with a for loop from 0 to 31. The start menu shows up with the value $02 ("...start menu/programs") and $0B (only "...start menu").

Can you confess this?

Or does this mean the value depends on the OS version ? o_0

Thanks again, great work. I'm such a lousy win coder :(. Currently I'm trying to generate a lnk file, thought it's easy, but even the file format description sounds like kind of a quantum physics encyclopedia to me.

EDIT
Currently it seems to me it's easiest to use a vbs script as explained here:
http://www.ss64.com/nt/shortcut.html

Works nicely.

So my app will create this vbs file at runtime, using the clients startmenu path etc, then execute it, finally delete it again.


b32(Posted 2006) [#5]
That method looks really great, I should really look into VBscript, because I believe it is really handy. As for the $02 value, I found this thread: http://www.blitzbasic.com/Community/posts.php?topic=45722
It seems that $02 is the programs folder in the start menu.
And I saw that blitzsys has a command concerning special folders.


jfk EO-11110(Posted 2006) [#6]
Outch, I shoulda have known, good old blitzsys. Now who said beef is harmless :o)

the temporary vbs works, as long as the OS has Windows Scripting Host active, which is default. Only a few people used to deactivate it for security reasons even for local execution. In my case where it's a lnk to an uninstaller of a screensaver, I think it isn't fatal if the uninstaller is missing on a few machines.


BTW: does value $02 point to your current users startmenu or to the one of All Users?


jfk EO-11110(Posted 2006) [#7]
Arrrrrrrrrgghh!! This is unbelievable. It takes me several days to create a simple screensaver installer/uninstaller :/

Everything works fine, only problem is:

When I run a shortcut that uses a commandline argument then this works ok with an ordinary EXE, but refuses to work when I call a SCR that is located in the system folder (as the screensaver.scr is). The idea is to run the original screensaver app with an argument "/UNINSTALL" to remove the whole thing. Currently there's only one file installed, a moleboxed SCR. I'd really like to have not too many files floating around. Any ideas?


b32(Posted 2006) [#8]
I tried "RunTimeError CommandLine$()", it seems that a .scr file is ran with the /s parameter by default.


jfk EO-11110(Posted 2006) [#9]
You're right. Thought windows will start a screensaver with the /s parameter when it automaticly runs the SCR file. I was surprised to see it also altered the commandline of the LNK shortcut from "/UNINSTALL" to "/s" when clicked in the start menu.
Ok, currently I ain't see no better solution than an additional exe.


b32(Posted 2006) [#10]
Instead of using the commandline, maybe you could set an environment variable when deinstalling ?


jfk EO-11110(Posted 2006) [#11]
Thought I alread answered here... strange...
I don't think the LNK file can set an enviroment variable. and it needs to be executed using the LNK shortcut from the startmenu.


jfk EO-11110(Posted 2007) [#12]
It seems this issue was discussed in two threads. anyhow, the last idea was the desinstaller would first copy itself to the windows TEMP dir, then run this copy, then end itself. The running copy in the TEMP dir would then wait a few seconds and finally delete the uninstaller. The user may delete the content of the TEMP dir from time to time, that's the purpose of it.

However, I just triedSHGetSpecialFolderPath that worked well for the start menu path etc.. Unfort. it seems it cannot tell me the path of the windows temp dir. Is there an other way to optain the TEMP folder path?

EDIT uh well never mind, its.

GetEnv$("TEMP")