Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

creating a shortcut

 [1/34] from: maarten:vrijheid at: 28-Oct-2003 11:11


Hi, I have built an installer and I'd like to let it create a shortcut, quicklaunch and start menu entry under windows. But (as happens more and more ;-) ) I haven't got a clue. Help? --Maarten

 [2/34] from: greggirwin:mindspring at: 28-Oct-2003 21:48


Hi Maarten, MK> I have built an installer and I'd like to let it create a shortcut, MK> quicklaunch and start menu entry under windows. I did it a long time ago under VB, but it was a real pain IIRC. I think the new shell extension COM objects make it pretty easy from VB now, but that won't help us here. Maybe the best bet is Windows Scripting Host. Didn't someone do something on that a while back? -- Gregg

 [3/34] from: maarten:vrijheid at: 29-Oct-2003 8:23


Hi Gregg, How can I drive the scripting host then? I am a real Windows nitwit.... (and now you see why I asked you offline what I asked you, being our Windows hero ;-) ) --Maarten

 [4/34] from: greggirwin:mindspring at: 29-Oct-2003 8:21


Hi Maarten, MK> How can I drive the scripting host then? I am a real Windows nitwit.... MK> (and now you see why I asked you offline what I asked you, being our MK> Windows hero ;-) ) :) You should be able to create a VBS (VB Script) file and call that. It's kind of a kludge (IMO), and VB Script isn't all that capable, but it is COM enabled. Another option would be to use VB (or something else), to create a small EXE that does what you need and embed that in your distro. The catch, of course, is all the dependencies it can generate. -- Gregg

 [5/34] from: bry:itnisk at: 29-Oct-2003 17:42


MK> How can I drive the scripting host then? I am a real Windows nitwit.... MK> (and now you see why I asked you offline what I asked you, being our MK> Windows hero ;-) ) You probably shouldn't call Wscript in something you're intending to give to customers, two issues could be: 1. Wscript turned off, for security reasons, by administrators. 2. older versions of Wscript different from what you're using. Of course number two can be a problem in any windows scenario. But I figure the problem is probably worsened the higher up the tool is you're using. I would have answered this earlier but I was sick the last two days and forgot: What you want to do is to make a desktop shortcut correct? If so you might want to consider making what is known as a Shell Instance Object, Here's an overview of these: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwui/h tml/shellinstobj.asp And here is an example that goes ahead and makes a shortcut to Notepad, and prompts you with a message when you try to remove it: http://www.cheztabor.com/dtshortcut/ since this is all done through the registry you should be able to handle it from rebol/view pro and higher I think (isn't there a registry dialect out there somewhere?)

 [6/34] from: bry:itnisk at: 29-Oct-2003 17:59


Note the shell command object shown in that Microsoft link: HKEY_CLASSES_ROOT CLSID {D4480A50-BA28-11d1-8E75-00C04FA31A86}=REG_SZ:"Add Network Place" InfoTip=REG_SZ:"Connects to shared folders, Web folders, and FTP sites." DefaultIcon=REG_EXPAND_SZ:"%SystemRoot%\System32\netplwiz.dll,-107" ShellFolder Attributes=REG_DWORD:0x00000000 Shell Open Command=REG_EXPAND_SZ:"rundll32 ..."

 [7/34] from: bry:itnisk at: 29-Oct-2003 18:01


>What you want to do is to make a desktop shortcut correct? If so you >might want to consider making what is known as a Shell Instance Object,
note that this also has compatibility problems, I don't think it's supported in Windows 98 on down.

 [8/34] from: greggirwin:mindspring at: 29-Oct-2003 10:31


Hi Bryan, b> since this is all done through the registry you should be able to handle b> it from rebol/view pro and higher I think (isn't there a registry b> dialect out there somewhere?) Yeah, the problem is that anytime MS provides an interface, like IShellLink, for doing this kind of thing and you circumvent it by going directly to the registry, you can end up making a lot more work for yourself. e.g. sometimes different Windows versions do things differently, so you need to find out what version you're on etc. I'm not sure in this case though. -- Gregg

 [9/34] from: maarten:vrijheid at: 29-Oct-2003 20:11


Well the thing is.... AltME (for example) does this in REBOL so it is possible in a way that it runs on all platforms. Sigh. --Maarten Gregg Irwin wrote:

 [10/34] from: bry:itnisk at: 29-Oct-2003 20:59


well I'm supposing AltME is written in the rebol sdk version so it's probably using IShellLink, however the following hack might also be a solution, this should work on windows 98 on up: cShortcut: {[InternetShortcut] URL=file:///c:\ Modified=9088F98B4E9EC3014C} write %test.url cShortcut by the way this can be used with that nifty asynchronous pluggable protocol thingee to write clickable scripts all over (just saying.) :) I'm not sure what the modified value is for in the url format so I just copied from something on my system. you might want to find out what it means.

 [11/34] from: greggirwin:mindspring at: 29-Oct-2003 13:15


Hi Maarten, MK> Well the thing is.... AltME (for example) does this in REBOL so it is MK> possible in a way that it runs on all platforms. Yup. Very likely just writing to the registry. -- Gregg

 [12/34] from: greggirwin:mindspring at: 29-Oct-2003 14:12


Hi bry, bic> well I'm supposing AltME is written in the bic> rebol sdk version so it's probably using bic> IShellLink REBOL can't do COM though. Unless the folks at Profilific figured out a way. bic> ...asynchronous pluggable protocol thingee... That's what I was thinking with my original post (or somewhere back there) I think. -- Gregg

 [13/34] from: tbrownell:y:ahoo at: 29-Oct-2003 15:24


Microsoft Windows 95 and Windows 98 only support IShellLinkA.

 [14/34] from: james:mustard at: 24-Dec-2003 22:43


Hi guys - we discussed this back in October '02 for the simple making of shortcuts under windows (except windows 95 - you need the windows scripting plugin). ########################################### PLease note - if you do NOT have access to Pro then you can use the browse functionality to launch the *.sh script file - or if you are feeling particularly clever, you can redirect the browser from explorer.exe to wscript.exe. ################################### Ashley wrote:
> I don't suppose there is a handy one for "create a short-cut on the > desktop" regardless of what Windows version it is? ;)
The easiest way I know of (which doesn't depend on esoteric fCreateShell dll calls) is to call a windows scripting object file (a *.sh text file) which will get run by the windows scripting host (provided it is installed - default in win98 SE upwards - IIRC). then from rebol its a simple shell call using the ShellExecute API specifying the name of the script to call. a sample script file (sample.sh) could contain: ' ------------------------------------------ Set WSHShell = WScript.CreateObject("WScript.Shell") DesktopPath = WSHShell.SpecialFolders("Desktop") 'Create shortcut to database program Set MyShortcut = WSHShell.CreateShortcut(DesktopPath & "\I am a shortcut.lnk") with MyShortcut .TargetPath = "C:\wherever\whatever.exe" .WorkingDirectory = "C:\wherever" .WindowStyle = 4 .IconLocation = "C:\wherever\whatever.exe, 0" .Save end with ' ------------------------------------------ Regards, James.

 [15/34] from: greggirwin:mindspring at: 29-Oct-2003 17:18


Thanks James! -- Gregg

 [16/34] from: ed:brittlestar at: 29-Oct-2003 21:43


http://www.wotsit.org/ is a good site for tips/tricks relating to file formats. Look in the Windows Files section for .LNK or .URL files. // Ed

 [17/34] from: maarten:vrijheid at: 30-Oct-2003 8:11


And this is what Cal mailed me.... (thanks Cal!)
>> ? create-link
USAGE: CREATE-LINK source dest /start dir /note desc /args arg-str DESCRIPTION: Creates file links. CREATE-LINK is a native value. ARGUMENTS: source -- File to link to (Type: string file) dest -- Name for new link (Type: string file) REFINEMENTS: /start dir -- Directory to start in (Windows) (Type: string file) /note desc -- Link description text (Windows) (Type: string) /args arg-str -- Provide command arguments (Type: string none) It is in the SDK. Another reason why I am a happy SDK user.... --Maarten

 [18/34] from: bry:itnisk at: 30-Oct-2003 10:22


Okay, I don't have the sdk yet, does create-link create .lnk files (these file extensions are always hidden unless you do some registry fiddling)? You can check by opening it in a text editor (have to do this by drag and drop), if it's in the structure I sent you before it's a .url file, if it's something like the following: L  À F‹  /  PàOÐ ê:i¢Ø +00 #C:\ 1„ 2    - 1   ¦ŠÒ` C:\  . . \ . . \ . . Then it's a .lnk file. I suppose it makes sense just to have a function for .lnk files, .url files one can always write as plain text in the way I sent earlier.

 [19/34] from: maarten:vrijheid at: 30-Oct-2003 11:55


You should get it, it is well worth its money (especially the Command version). Anyway, using both SDKs (my private SDK copy and work-related Command) it works well for me if I supply the source as string. --Maarten

 [20/34] from: greggirwin:mindspring at: 30-Oct-2003 9:05


Hi Maarten, MK> And this is what Cal mailed me.... (thanks Cal!)
>>> ? create-link
Well, wouldn't you know. Those guys at RT think of everything. :) -- Gregg

 [21/34] from: atruter:labyrinth:au at: 31-Oct-2003 12:23


Good news indeed! So now I can create a Windows shortcut with the following: create-link/start "c:\MyApp\MyApp.exe" "c:\Documents and Settings\All Users\Desktop\MyApp.lnk" "c:\MyApp" on Windows2000/XP. I suppose on 95/98/ME I can check for the presence of c:\Windows and replace "c:\Documents and Settings\All Users\Desktop\MyApp.lnk" with "c:\Windows\Desktop\MyApp.lnk". Anyone come up with a better (more generic) approach to handle this? Regards, Ashley

 [22/34] from: antonr:iinet:au at: 31-Oct-2003 12:55


You should use to-local-file:
>> create-link to-local-file %/d/anton/dev/rebol/view/rebol.exe
%rebol-shortcut.lnk == true Anton.

 [23/34] from: bry:itnisk at: 31-Oct-2003 10:18


Well if you used call and redirected input couldn't you just get environment variables? There was also a registry dialect I saw once, if you used that I suppose you would be able to check the registry structure, not particularly stable a method either, but I think it's better than checking if c:\windows exists; I've worked with people who, in building programs would check if c:\winnt existed and if not create it so they could have a c:\winnt\system32 to put their dlls in and it took repeated explanations as to how to handle the problem correctly over a space of 6 months to get them to actually change their original code so as a consequence I don't believe in every checking against the existence of a folder and assuming from that what operating system one is in.

 [24/34] from: g:santilli:tiscalinet:it at: 31-Oct-2003 10:53


Hi Ashley, On Friday, October 31, 2003, 2:23:46 AM, you wrote: AT> up with a better (more generic) approach to handle this? Maybe using GET-ENV? Does Windows have variables pointing to the path of the various directories? Or maybe somewhere in the registry... Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [25/34] from: greggirwin:mindspring at: 31-Oct-2003 3:17


Hi Ashley, AT> on Windows2000/XP. I suppose on 95/98/ME I can check for the presence of AT> "c:\Windows" and replace "c:\Documents and Settings\All AT> Users\Desktop\MyApp.lnk" with "c:\Windows\Desktop\MyApp.lnk". Anyone come AT> up with a better (more generic) approach to handle this? If you have /Pro or the SDK, you can use the SHGetSpecialFolderLocation or SHGetFolderPath APIs to get the location of the desktop and other special folders. -- Gregg

 [26/34] from: bry:itnisk at: 31-Oct-2003 13:34


AT> up with a better (more generic) approach to handle this?
>Maybe using GET-ENV? Does Windows have variables pointing to the >path of the various directories? Or maybe somewhere in the >registry...
I guess GET-ENV is an sdk function. On my Windows 2000 there are six system variables that could be used to tell I was on an Winnt machine: 1. OS 2. Os2LibPath 3. ComSpec 4. Temp 5. Tmp 6. WinDir of course it is always possible that someone has erased one of these environment variables, but I doubt that people who do this have what might be considered as smoothly functioning windows machines anyway. Anyway if the sdk has GET-ENV then I suppose it must have a function to expand %SystemRoot%, perhaps by looking at the source you can find that?

 [27/34] from: g:santilli:tiscalinet:it at: 31-Oct-2003 14:23


Hi bryan, On Friday, October 31, 2003, 1:34:17 PM, you wrote: b> Anyway if the sdk has GET-ENV then I suppose it must have a function to b> expand %SystemRoot%, perhaps by looking at the source you can find that? REBOL/View 1.2.10.3.1 30-May-2003 Copyright 2000-2002 REBOL Technologies. All rights reserved. REBOL is a trademark of REBOL Technologies. WWW.REBOL.COM
>> get-env "OS"
== "Windows_NT"
>> get-env "SystemRoot"
== "C:\WINDOWS" Is there a variable for the desktop path, too? Otherwise we have:
>> help get-reg
USAGE: GET-REG key-path id /hkcr /hkcu /hklm /hku /hkcc /hkdd DESCRIPTION: Returns value of a registry key, else NONE. (HKCU is default) GET-REG is a native value. ARGUMENTS: key-path -- (Type: string) id -- (Type: string) REFINEMENTS: /hkcr /hkcu /hklm /hku /hkcc /hkdd
>> help set-reg
USAGE: SET-REG key-path id value /hkcr /hkcu /hklm /hku /hkcc /hkdd DESCRIPTION: Sets registry key value. Returns value on success, else NONE. (HKCU is default) SET-REG is a native value. ARGUMENTS: key-path -- (Type: string) id -- (Type: string) value -- (Type: any-string) REFINEMENTS: /hkcr /hkcu /hklm /hku /hkcc /hkdd Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [28/34] from: bry:itnisk at: 31-Oct-2003 15:48


b> Anyway if the sdk has GET-ENV then I suppose it must have a function to b> expand %SystemRoot%, perhaps by looking at the source you can find that? g>>> get-env "OS" g>== "Windows_NT" g>>> get-env "SystemRoot" g>== "C:\WINDOWS" This causes me to think that you must be running Windows XP or later? g>Is there a variable for the desktop path, too? Otherwise we have: Greg said something about a function to get special folders didn't he? This can be useful to get namespaced folders in the Windows Shell. Otherwise: http://www.onlimemedia.com/products/smartbackup/help/foldervariables.htm l

 [29/34] from: bry:itnisk at: 31-Oct-2003 16:15


USAGE: GET-REG key-path id /hkcr /hkcu /hklm /hku /hkcc /hkdd The support of HKEY_DYN_DATA is very interesting.

 [30/34] from: bry:itnisk at: 31-Oct-2003 16:40


Okay last one: REFINEMENTS: /hkcr /hkcu /hklm /hku /hkcc /hkdd just noticed there was no hkpd. Shoot, I really need to get my boss to put out for an sdk version...

 [31/34] from: g:santilli:tiscalinet:it at: 31-Oct-2003 17:30


Hi bryan, On Friday, October 31, 2003, 3:48:18 PM, you wrote: b> This causes me to think that you must be running Windows XP or later? Yup, XP here. :) Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [32/34] from: g:santilli:tiscalinet:it at: 31-Oct-2003 17:33


Hi bryan, On Friday, October 31, 2003, 4:40:17 PM, you wrote: b> Shoot, I really need to get my boss to put out for an sdk version... Again, that was from View 1.2.10, I have the Pro key but I think that those functions are available even without /Pro (and anyway, it would be cheaper than the SDK for you :). http://www.reboltech.com/downloads/view1210031.exe Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/

 [33/34] from: greggirwin:mindspring at: 31-Oct-2003 9:44


For the Windows and System dirs, there are two very easy API calls that return them. The other special folders are a bit trickier. Just an afterthought. :\ -- Gregg

 [34/34] from: rotenca:telvia:it at: 31-Oct-2003 18:14


Hi, all, I have added some info about function rebol changes in my site http://www.rebol.it/~romano/ , if you find errors/omissions let me know --- Ciao Romano