Archive: CreateShortcut problem


I have the following code in an NSIS script:

SetOutPath "$STARTMENU\Programs\PAWSoft\PAWClock"
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\PAWClock.lnk" "$INSTDIR\PAWClock.exe" "" "" 0
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\Read Me.lnk" "$INSTDIR\ReadMe.txt" "" "" 0
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\Whats New.lnk" "$INSTDIR\WhatsNew.txt" "" "" 0
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\Uninstall PAWClock.lnk" "$INSTDIR\Uninstall.exe" "" "" 0

This code works fine for me whatever I do, such as installing to a non-default location and installing on another partition.

Th problem is that I have a beta tester and the createshortcuts failed for him. He sent me this screenshot:

http://www.pawsoft.btinternet.co.uk/temp/NSISProb.gif

He later told me that he installed it to E:\win_util\pawclock

As I said I tested it myself on other partitions so I can't see how it could be that. Has anyone got any ideas why it might be failing or a way of getting more info?


Also, I have just noticed that NSIS has $SMPROGRAMS, is it better to use than $STARTMENU\Programs or is it just for convenience?


Just got another response from the tester with this problem:

Just in case it matters, I am using Windows ME and yes, other programs install okay. I checked the c:\program file directory because it is still there. I notice the error is referring to c:\windows\start menu\program and this directory is present. I tried three times and used the defaults and it still shows the error.

Please, has anyone seen this sort of error with CreateShortcut before? I hope it is only local to his system, but it is a worry either way.


Create Shortcut bug...
I've noticed that if the folder doesn't exist on my start menu under programs that the shortcuts don't get created there. Maybe that was the problem. I have to copy a file to the place I want to create the shortcuts and then delete the file. Then I can create my shortcuts successfully. I don't have any problems creating shortcuts anywhere else.

--tale


Ok SMPROGRAMS (if that is correct) is much better to use.

Why? Well because it's not always start menu/programs.

I had some Dannish user complaining to me that it had created programs on his machine instead of putting it in his programma folder.

So I posted on the beta list, and the nice person on the list(craigf I think it was) provided me (/me no like c) with a fix, and next release something similar turned up. Cool.

Anyway I digress.

CreateShortcut requires the folders to already exist, you have to create the folder in the SMPROGRAMS then create shortcut in there, which I see you are doing.

Next it's the icon issue. I see you are using icon 0 in a non-extant file. Oh dear. If you want to specify an icon you have to specify the file too! If you don't specify either it works, if you specify one you have to specify the other.

e.g.

SetOutPath "$STARTMENU\Programs\PAWSoft\PAWClock"
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\PAWClock.lnk" "$INSTDIR\PAWClock.exe" "" $INSTDIR\PAWClock.exe 0
If you want to default:
SetOutPath "$STARTMENU\Programs\PAWSoft\PAWClock"
CreateShortCut "$STARTMENU\Programs\PAWSoft\PAWClock\PAWClock.lnk" "$INSTDIR\PAWClock.exe"
Will do fine.

My script has been completely rewritten in the 3 weeks since I posted that first message. It is now much better and has not failed in any situation so far. Part of the problem was with an NSIS bug in 1.3 but that has all been fixed now in the latest versions.


DOH!

/me notices dates of PsyPab's posts

Well that will teach me to read the forums in such a rush.

Ah dagnamit. Better late than never ;-)


Doesn't matter, I would probably have appreciated it at the time.

I hardly ever check the post date, so I can see how easy it could have happened. Especially in a forum as slow moving as this one (NSIS).