ZileXa Posted March 27, 2006 Share Posted March 27, 2006 (edited) You might think this is a stupid question, well it is not:1 method, must work for ALL WinXP languages!Why?I have created a small rar SFX, that will run a .cmd file that will extract some software to %programfiles%.Now I want (this .cmd to create..) shortcuts for these apps in the %allusers% Start Menu\Programs. (rar sfx cannot create them in allusers, only for current logged in user).This would be soo easy, but here is the tricky part:I want to be able to run this one rarsfx, wich will start a .cmd file, on ALL languages of Windows XP and create shortcuts.The problem is, Start Menu\Programs has got different names in the different WinXP versions.EXAMPLE:Start menu (English Windows), Menu Start (Dutch Windows), menu inicio (Spanish).It would be easy if there was something like %menustartprograms% but this doesn't exist.WHO knows a way??I post it in uA Windows because I believe there are some experts on this area here. Edited March 27, 2006 by ZileXa Link to comment Share on other sites More sharing options...
Djé Posted March 27, 2006 Share Posted March 27, 2006 You may build your own %menustartprograms% and more by having a look at:HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Foldersand the SM_ values at:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion Link to comment Share on other sites More sharing options...
ZileXa Posted March 27, 2006 Author Share Posted March 27, 2006 uhm, either I don't understand or you don't. 1 rarsfx file, when executed it runs a batchfile that will create shortcuts. How can this batchfile 'know' for wich folders to build the %menustartprograms%? it could be for menu inicio, start menu, menu start...I think you want me to prepare the pc first by creating this, but thats not possible... otherwise I wouldnt have the problem of languages.but thanks for the idea Link to comment Share on other sites More sharing options...
Yzöwl Posted March 27, 2006 Share Posted March 27, 2006 (edited) Try using either VBS or INF insteadVBSConst STMENPROG = &H2&Const MYDOCUMENTS = &H5&Const WINDOWS = &H24&Set oShell = CreateObject("Shell.Application")Set oAllStMen = oShell.Namespace(STMENPROG).SelfSet oMyDocu = oShell.Namespace(MYDOCUMENTS).SelfSet oWinDir = oShell.Namespace(WINDOWS).SelfSet WShell = WScript.CreateObject("WScript.Shell")Set oShellLink = WShell.CreateShortcut(oAllStMen.Path &"\Notepad.lnk")oShellLink.TargetPath = oWinDir.Path &"\notepad.exe"oShellLink.WorkingDirectory = oMyDocu.PathoShellLink.SaveINF (ProfileItems)[Version]Signature = $Windows NT$[DefaultInstall]ProfileItems = TestLink[TestLink]Name = Notepad,1CmdLine = 10,,notepad.exeWorkingDir = 16389INF (UpdateInis)[Version]Signature = $Windows NT$[DefaultInstall]UpdateInis = TestLink[TestLink]setup.ini, progman.groups,, "group0=""%16386%\"""setup.ini, group0,,"Notepad,""""""%10%\notepad.exe"""""",,,,""%16389%"""</Edit> Edited March 27, 2006 by Yzöwl Link to comment Share on other sites More sharing options...
Djé Posted March 27, 2006 Share Posted March 27, 2006 uhm, either I don't understand or you don't.I think I understood you .What I was trying to say is that the values you are looking for (the path/name of the start menu and other folders in the local language is stored in the registry at the keys I gave you. Just run regedit and navigate to these keys and you will see what I'm talking about.You can follow Yzöwl and switch to vbs or inf syntax, where there are built-in constants for the names of these folders so it's easy to use. If you want to stick to batch syntax, here are a few tips:To have a %menustartprograms% variable AUTOMATICALLY containing the name of the start menu in the local language, you first need to have your batch look for that name in the registry and then AUTOMATICALLY attribute it to your variable.- The batch command to access the registry is REG. Type REG /? for more details.- For reading a value %VALUE% in the %KEY% key you would use:REG QUERY "%KEY%" /V %VALUE%- To create a variable and store data in it, you have to use the SET command. Type SET /? for more details.- For storing myvarvalue in the %MyVar% variable, you would use:SET MyVar=myvarvalue- To link the 2 previous commands so you can store the result of the query in your variable, you need the FOR command. Type FOR /? for more details.- Now your full command line to get your %menustartprograms% should be:FOR /F "skip=4 tokens=2*" %%I IN ('REG QUERY "%KEY%" /V %VALUE%') DO SET menustartprograms=%%Jwhere %KEY% and %VALUE% are variables that you would have previously set to the registry key and value that you want to query(total to get your local-language-start-menu-name in a variable: 3 lines). You can also write directly the key and value of the REG QUERY command, instead of setting variables(total to get your local-language-start-menu-name in a variable: 1 line (quite complicated, I must admit). - If ever the value you are querying contains a variable (like %SystemRoot%) you'll have to replace DO SET by DO CALL SET to have it properly expanded.Ok, now I know all those commands look cryptic at first, but that's normal at the beginning and with the help of us here, of some good pages about batch scripting on the web and of your best friend /?, no doubt you will succeed. Link to comment Share on other sites More sharing options...
ZileXa Posted March 27, 2006 Author Share Posted March 27, 2006 (edited) Yzöwl thanks for the response and the nice examples! Seems some nice things can be done with VBS and INF.Djé, actually that is just what I wanted and it is not that complicated at all. I've seen some .cmd files and experimented with them. I have had some Java courses in college... actually still have to do 1 java course for my bachelor. the FOR / DO thing is very familiar to me I don't really know what the "skip=4 tokens=2* is for but doesn't matter. If needed I can figure that out myself.Thanks a lot!I know some people remove VBS with Nlite... I prefer the method you suggested. But INF might also be nice.I will experiment with the methods! also thanks for the link. I couldn't find any good source for more info about batchfiles.IT WORKS!I figured out the tokens/skip thing a little bit, because it wasn't working instantly. The usual trial/error gave me a working test.I made a batchfile and edited/runned it untill it worked:FOR /F "skip=4 tokens=3*" %%I IN ('REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V "Common Programs"') DO SET menustartprograms=%%JDEL "%menustartprograms%\WinRAR.lnk"PAUSE(used pause to see if the command was running well.)Now I will use it to copy an extracted folder with shortcuts to the correct location. Thanks A LOT!I will use it in my DVD-ReBuilder Easy Installer. It has become very popular since I created an English website for it. But my method of creating the shortcuts didn't seem to work for other languages then Dutch. Now with this method it will work flawless Edited March 27, 2006 by ZileXa Link to comment Share on other sites More sharing options...
BoardBabe Posted March 28, 2006 Share Posted March 28, 2006 You can do this very simple by using AutoIt, as AutoIT has a built in variable for %AllUsersProfile%\Start-menu\programs. Link to comment Share on other sites More sharing options...
ZileXa Posted March 28, 2006 Author Share Posted March 28, 2006 thanks, I know AutoIt as well, in fact I use it a few times for my uAdisc. But for this it isn't really necessary. Link to comment Share on other sites More sharing options...
Djé Posted March 30, 2006 Share Posted March 30, 2006 (edited) Bad news, ZileXa:That batch thing doesn't work (as for now) for ALL LANGUAGES, as you specified.Indeed, some cryptic local dialects such as french have accented letters in those path and cmd is horrible at dealing with them:- if you type the command directly, it will display the result correctly with nice accents- but if you want to use the output of the command, or a text file, then it messes up everything between ANSI & OEM.And my Menu Démarrer (Start Menu) becomes an ugly Menu DÚmarrer.Myself, I would become a DjÚ Can you imagine that?I don't know how to overcome that yet.Anyone has a suggestion? appart from learning another language?<Edit>Good news, ZileXa:I was about to start learning vbs (especially after I saw Yzöwl's new example above) when I heared a voice in my head "Google ... goooogle ... google...".So here is what DigitalMother provided for us in her goodness:CHCP 1252FOR /F "skip=4 tokens=3 delims= " %%? IN (' REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V "Common Startup"') DO ( CHCP 850 SET Startup=%%?)Where CHCP is the command for changing code page, 850 being the code page used by CMD and 1252 (my) windows' one, I guess.Please also note the change in the FOR syntax (I'm copying on the master) to cope for reg values containing space in their names: - tokens=3 only- delims= {TAB} ONLY- %%I and %%J replaced by %%? </Edit> Edited March 30, 2006 by Djé Link to comment Share on other sites More sharing options...
Yzöwl Posted March 30, 2006 Share Posted March 30, 2006 Just for information for anyone who didn't understand, the methods I provided in my examples were not just to find the correct folder locations, they actually create the shortcuts on the fly too. As a batch freak, I would have provided a batch method, had I not had to also use vbs or inf with it in order for the shortcut creation. Link to comment Share on other sites More sharing options...
ZileXa Posted April 1, 2006 Author Share Posted April 1, 2006 So here is what DigitalMother provided for us in her goodness:CHCP 1252FOR /F "skip=4 tokens=3 delims= " %%? IN (' REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V "Common Startup"') DO ( CHCP 850 SET Startup=%%?)Where CHCP is the command for changing code page, 850 being the code page used by CMD and 1252 (my) windows' one, I guess.Please also note the change in the FOR syntax (I'm copying on the master) to cope for reg values containing space in their names: - tokens=3 only- delims= {TAB} ONLY- %%I and %%J replaced by %%? </Edit>Uhm, just asking to be sure, do I need the first line? "CHCP 1252"Because this could be different for other Windows languages if I understand correctly.. Link to comment Share on other sites More sharing options...
Delprat Posted April 1, 2006 Share Posted April 1, 2006 Uhm, just asking to be sure, do I need the first line? "CHCP 1252"Because this could be different for other Windows languages if I understand correctly..Yes : 1252 is the American-US codepageYou'll need to change the "CHCP 850" (which is the Western European codepage) to your own (CHCP with no arguments shows what number to use)PS: @ Djé : CHCP 1252FOR /F "skip=4 tokens=3 delims= " %%? IN (' REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V "Common Startup"') DO ( CHCP 850 SET Startup=%%?)this code is not portable to another language than Western European ones... you should change it to guess the codepage :FOR /F "tokens=2 delims=:" %%c IN ('CHCP') DO SET CodeP=%%cCHCP 1252FOR /F "skip=4 tokens=3 delims= " %%? IN (' REG QUERY "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders" /V "Common Startup"') DO (rem no space in the line below, it's in %CodeP% CHCP%CodeP% SET Startup=%%?)and you can update your 5in1 theme script Link to comment Share on other sites More sharing options...
ZileXa Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) hmmm... thanks Delprat, but still it will use the American US codepage, so fail for French version? I am little bit confused now because there is still the line CHCP 1252. Or does it check wich codepage is used on the system first? It works on my system (Dutch version). it seems using the .INF method would be lot easier... Edited April 2, 2006 by ZileXa Link to comment Share on other sites More sharing options...
Delprat Posted April 2, 2006 Share Posted April 2, 2006 (edited) hmmm... thanks Delprat, but still it will use the American US codepage, so fail for French version? I am little bit confused now because there is still the line CHCP 1252. Or does it check wich codepage is used on the system first? It works on my system (Dutch version).850 and 1252 are both "Occidental" codepages.850 is called "IBM" or "DOS"1252 is called "Windows" or "Windows ANSI" (and is the default Windows CP for North America and Western Europe)(sorry for the mistake in my precedent post)Both allows the same characters, but shifted ; so some of them f*ck the batch (as the é in "démarrage"="startup" in french ; which is converted on-the-fly to a coma in %Startup%)but there isn't such letters in dutch (i presume), so the two CHCP are pointless and you can remove them.(and, yes, the "patch" i posted checks your codepage before to allow the batch to run with characters not represented in the 850 codepage -- even if i don't know of any applicable to the "common startup" folder )it seems using the .INF method would be lot easier...Agreed. it's not "easier", it's simply "straight-forward".The VBS is great also. Edited April 2, 2006 by Delprat Link to comment Share on other sites More sharing options...
ZileXa Posted April 2, 2006 Author Share Posted April 2, 2006 (edited) Thanks, I understand!Agreed. it's not "easier", it's simply "straight-forward".Yes, that's what I should've sad Edited April 2, 2006 by ZileXa Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now