Home All Groups Group Topic Archive Search About

create desktop shortcut when app installed w/P&D installer for XP,Vista,W7

Author
6 Sep 2010 2:35 AM
Mike S
I want to modify the installer to create a desktop shortcut when a
program is installed. I found this discussion
http://www.vbforums.com/showthread.php?t=451311
that explains, "by adding just 4 lines of code, the Packaging &
Deployment Wizard and Setup1.vbp can be easily modified to create
Desktop shortcuts, as well as Start Menu shortcuts."
http://www.freevbcode.com/ShowCode.asp?ID=3650
I was wondering how this looked to people here, and if there are other
approaches that might be better.

Author
6 Sep 2010 2:49 AM
Nobody
"Mike S" <ms***@yahoo.com> wrote in message
news:i61k16$sjp$1@news.eternal-september.org...
>I want to modify the installer to create a desktop shortcut when a program
>is installed. I found this discussion
> http://www.vbforums.com/showthread.php?t=451311
> that explains, "by adding just 4 lines of code, the Packaging & Deployment
> Wizard and Setup1.vbp can be easily modified to create Desktop shortcuts,
> as well as Start Menu shortcuts."
> http://www.freevbcode.com/ShowCode.asp?ID=3650
> I was wondering how this looked to people here, and if there are other
> approaches that might be better.

I would recommend that you use Inno Setup ANSI version, which doesn't
require runtime, and works from Windows 95 to 7. It already natively support
many things you would need to modify PDW for, such as showing license files,
and adding keys and values to anywhere in the registry, and so on. Just run
the wizard and fill the information, then check this how to article:

http://www.jrsoftware.org/iskb.php?vb
http://www.jrsoftware.org/isinfo.php
Author
6 Sep 2010 3:01 AM
Mayayana
See here for two versions of modified PDW that
include updates like Desktop shortcut, app path
folder creation, permission changing on folders, etc:

http://www.jsware.net/jsware/vbcode.php5

  The thread you linked to shows two ways of
creating a shortcut. One uses a function from
vb6stkit.dll, which is OK *if* you can get it to
work. The other is a hokey method using wscript.shell
that *should not* be used. The files linked above
use the shelllnk.tlb for VB.



Show quoteHide quote
|I want to modify the installer to create a desktop shortcut when a
| program is installed. I found this discussion
| http://www.vbforums.com/showthread.php?t=451311
| that explains, "by adding just 4 lines of code, the Packaging &
| Deployment Wizard and Setup1.vbp can be easily modified to create
| Desktop shortcuts, as well as Start Menu shortcuts."
| http://www.freevbcode.com/ShowCode.asp?ID=3650
| I was wondering how this looked to people here, and if there are other
| approaches that might be better.
|
Author
6 Sep 2010 3:43 AM
Mayayana
Just to expand on that last post a bit...

Setup1 from the PDW is an interesting project
that includes all of the functionality needed for
an installation. It's really whatever you want it
to be. But you need to be willing to spend a
little time getting familiar with it.

Also note that when making changes you should
take care to log them in the uninstall log. The code
you linked to doesn't do that, but it's easy to do.
The functions are in vb6stkit.dll and they're amply
demonstrated in the setup1 code. If you look at
the code in the link I posted above there's a function
called DoDeskLink. It includes these lines:

NewAction GstrKEY_PRIVATEFILE, QUOTEMARK & sLNKPath & QUOTEMARK
AddActionNote "Desktop link created."
CommitAction

Those lines write to the ST6UNST.LOG file in the
program folder, which is used for uninstall. They
write lines something like:

ACTION: PrivateFile: "C:\Documents and Settings\All
Users\Desktop\SomeProgram.LNK"
(Desktop link created.)

  With the CommitAction call those lines are written to
the log. So when your program is uninstalled the Desktop
shortcut will be removed. You can do the same for
custom Registry settings, folder creation, etc. Just log
them and they'll be undone at uninstall. (See any uninstall
log file from a VB6 install to see how that works.)

  The No-Setup.exe version I linked to also has a
simple class for setting permissions on files/folders/
Registry keys.

    So you can customize your install in
all sorts of ways, and still have it cleanly removed
by the standard PDW uninstaller. But be careful with
vb6stkit.dll. It's specially designed for the PDW.
OSfCreateShellLink may work OK, but you need to
test it. The shelllnk.tlb method is probably safer.
An example of the kind of quirks you'll find with
vb6stkit.dll: It has a function ExtractFileFromCab that
looks quite handy. But if I remember correctly that
function is actually hardcoded to look for the CAB
in the Windows folder (!), because the PDW normally
moves the CAB file there before proceeding with install.
Author
6 Sep 2010 4:05 AM
Tony Toews
On Sun, 5 Sep 2010 23:43:27 -0400, "Mayayana"
<mayayana@invalid.nospam> wrote:

>The shelllnk.tlb method is probably safer.

Agreed.   Access Developers have been using my Auto FE Updater utility
since Version 1.3 - 2002/04/10 to create shortcuts which uses the
shellnk.tlb method.    There have been thousands of downloads per
year.   And I've never had one complaint about my utility creating
shortcuts ranging from Windows 98 to Windows 7.

Well, ok, I've added a few features over the years and Win Vista made
the Common Desktop to be updateable only with admin privileges but
I've never had one complaint about the basic functionality. 

Tony


--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Author
6 Sep 2010 2:17 PM
Mayayana
| >The shelllnk.tlb method is probably safer.
|
| Agreed.   Access Developers have been using my Auto FE Updater utility
| since Version 1.3 - 2002/04/10 to create shortcuts which uses the
| shellnk.tlb method.    There have been thousands of downloads per
| year.

I've used it for years, too. And it's the official
MS approach for VB. (If something marked
"unsupported" can be considered official.)

  Then again, you're the guy who made sense out
of Wix in a matter of hours, so you're clearly no
mere mortal. :)
Author
6 Sep 2010 8:07 PM
Tony Toews
On Mon, 6 Sep 2010 10:17:47 -0400, "Mayayana"
<mayayana@invalid.nospam> wrote:

>  Then again, you're the guy who made sense out
>of Wix in a matter of hours, so you're clearly no
>mere mortal. :)

<blush>  Thanks.  But all I needed to do was install one DLL using an
MSI file.  And the tutorial handled all my requirements so I just
followed the instructions and cut and pasted as appropriate.   

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Author
6 Sep 2010 8:35 PM
Kevin Provance
"Mayayana" <mayayana@invalid.nospam> wrote in message
news:i62t31$gdn$1@news.eternal-september.org...
:
:  Then again, you're the guy who made sense out
: of Wix in a matter of hours, so you're clearly no
: mere mortal. :)

I had to see what that was all about - Wix.  What a cool package.  I love
the cooresponding candle names.  Don't get me wrong, I am Inno loyal, but I
need to check this out too.  Thanks!
Author
6 Sep 2010 10:33 PM
Tony Toews
On Mon, 6 Sep 2010 16:35:49 -0400, "Kevin Provance" <k@p.c> wrote:

>:  Then again, you're the guy who made sense out
>: of Wix in a matter of hours, so you're clearly no
>: mere mortal. :)
>
>I had to see what that was all about - Wix.  What a cool package.  I love
>the cooresponding candle names.  Don't get me wrong, I am Inno loyal, but I
>need to check this out too.  Thanks!

AFAIK Inno can't produce MSI files.  And I wanted MSI files because I
think that IT admins will be more comfortable installing MSI files
especially remotely.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
  updated see http://www.autofeupdater.com/
Author
7 Sep 2010 7:39 AM
Dee Earley
On 06/09/2010 21:35, Kevin Provance wrote:
>
> "Mayayana"<mayayana@invalid.nospam>  wrote in message
> news:i62t31$gdn$1@news.eternal-september.org...
> :
> :  Then again, you're the guy who made sense out
> : of Wix in a matter of hours, so you're clearly no
> : mere mortal. :)
>
> I had to see what that was all about - Wix.  What a cool package.  I love
> the cooresponding candle names.  Don't get me wrong, I am Inno loyal, but I
> need to check this out too.  Thanks!

Yeah, I have an Inno and a WiX installer side by side for my toy project
at home.
Note really done much with WiX yet though.
Inno still looks nicer out the box :p

--
Dee Earley (dee.ear***@icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
Author
7 Sep 2010 5:50 AM
Mike S
On 9/5/2010 8:43 PM, Mayayana wrote:
Show quoteHide quote
> Just to expand on that last post a bit...
>
>   Setup1 from the PDW is an interesting project
> that includes all of the functionality needed for
> an installation. It's really whatever you want it
> to be. But you need to be willing to spend a
> little time getting familiar with it.
>
>   Also note that when making changes you should
> take care to log them in the uninstall log. The code
> you linked to doesn't do that, but it's easy to do.
> The functions are in vb6stkit.dll and they're amply
> demonstrated in the setup1 code. If you look at
> the code in the link I posted above there's a function
> called DoDeskLink. It includes these lines:
>
> NewAction GstrKEY_PRIVATEFILE, QUOTEMARK&  sLNKPath&  QUOTEMARK
> AddActionNote "Desktop link created."
> CommitAction
>
> Those lines write to the ST6UNST.LOG file in the
> program folder, which is used for uninstall. They
> write lines something like:
>
> ACTION: PrivateFile: "C:\Documents and Settings\All
> Users\Desktop\SomeProgram.LNK"
> (Desktop link created.)
>
>    With the CommitAction call those lines are written to
> the log. So when your program is uninstalled the Desktop
> shortcut will be removed. You can do the same for
> custom Registry settings, folder creation, etc. Just log
> them and they'll be undone at uninstall. (See any uninstall
> log file from a VB6 install to see how that works.)
>
>    The No-Setup.exe version I linked to also has a
> simple class for setting permissions on files/folders/
> Registry keys.
>
>      So you can customize your install in
> all sorts of ways, and still have it cleanly removed
> by the standard PDW uninstaller. But be careful with
> vb6stkit.dll. It's specially designed for the PDW.
> OSfCreateShellLink may work OK, but you need to
> test it. The shelllnk.tlb method is probably safer.
> An example of the kind of quirks you'll find with
> vb6stkit.dll: It has a function ExtractFileFromCab that
> looks quite handy. But if I remember correctly that
> function is actually hardcoded to look for the CAB
> in the Windows folder (!), because the PDW normally
> moves the CAB file there before proceeding with install.

I decided to take the plunge and try Inno Setup, I have to say Inno is a
really impressive program. 31 lines in the script let me install the VB
support files and my program files and custom folders, and it gives the
user the options of creating desktop or quicklaunch shortcut icons, with
full uninstall; really impressive program.
Author
7 Sep 2010 9:27 PM
Nobody
"Mike S" <ms***@yahoo.com> wrote in message
news:i64jr1$c7k$1@news.eternal-september.org...
> I decided to take the plunge and try Inno Setup, I have to say Inno is a
> really impressive program. 31 lines in the script let me install the VB
> support files and my program files and custom folders, and it gives the
> user the options of creating desktop or quicklaunch shortcut icons, with
> full uninstall; really impressive program.

If you are installing OCX files and other shared files(You have used
sharedfile flag), then also add the flag uninsnosharedfileprompt, otherwise,
the user is asked during uninstall that a shared file is not needed by any
other application, and asks the user what to do. Most users don't know what
to choose, so they get confused. So use this flag so they don't see this
prompt.

Also, on your files, such as the EXE and any files that may be in use, use
the flags "restartreplace" and "uninsrestartdelete". If you don't, the
installation would fail(and rollback any changes) if some files where in
use. Without "uninsrestartdelete" flag, if the user uninstalled your
application while it still running, the uninstallation succeeds, but the EXE
is left in the user's system and it would not be deleted on the next
restart.

Inno has an AppMutex setting in [Setup] section that you can use so it shows
an error message if your application is still running. There is a VB sample
in the help under that setting in how to use it.
Author
7 Sep 2010 9:56 PM
Abhishek
I use the neveruninstall flag on shared files like:

Source: Comdlg32.ocx; DestDir: {sys}; Flags: regserver uninsneveruninstall


Show quoteHide quote
"Nobody" <nob***@nobody.com> wrote in message
news:i66apf$ntr$1@speranza.aioe.org...
| "Mike S" <ms***@yahoo.com> wrote in message
| news:i64jr1$c7k$1@news.eternal-september.org...
| > I decided to take the plunge and try Inno Setup, I have to say Inno is a
Author
7 Sep 2010 10:19 PM
Nobody
"Abhishek" <u***@server.com> wrote in message
news:i66cdg$qsd$1@speranza.aioe.org...
>I use the neveruninstall flag on shared files like:
>
> Source: Comdlg32.ocx; DestDir: {sys}; Flags: regserver uninsneveruninstall

That's not a shared file if it doesn't have sharedfile flag, which is what
the VB article includes.

http://www.jrsoftware.org/iskb.php?vb
Author
7 Sep 2010 10:06 PM
Mike S
On 9/7/2010 2:27 PM, Nobody wrote:
<snip>
Show quoteHide quote
> If you are installing OCX files and other shared files(You have used
> sharedfile flag), then also add the flag uninsnosharedfileprompt, otherwise,
> the user is asked during uninstall that a shared file is not needed by any
> other application, and asks the user what to do. Most users don't know what
> to choose, so they get confused. So use this flag so they don't see this
> prompt.
>
> Also, on your files, such as the EXE and any files that may be in use, use
> the flags "restartreplace" and "uninsrestartdelete". If you don't, the
> installation would fail(and rollback any changes) if some files where in
> use. Without "uninsrestartdelete" flag, if the user uninstalled your
> application while it still running, the uninstallation succeeds, but the EXE
> is left in the user's system and it would not be deleted on the next
> restart.
>
> Inno has an AppMutex setting in [Setup] section that you can use so it shows
> an error message if your application is still running. There is a VB sample
> in the help under that setting in how to use it.

I used the AppMutex after that was suggested in the innosetup.code
newsgroup, and I read the help files. I used API as much as possible,
and didn't use any ocx files, it's a pretty simple program. Thanks.
Author
7 Sep 2010 3:50 PM
Jeff Johnson
"Mike S" <ms***@yahoo.com> wrote in message
news:i61k16$sjp$1@news.eternal-september.org...

>I want to modify the installer to create a desktop shortcut when a program
>is installed. I found this discussion
> http://www.vbforums.com/showthread.php?t=451311
> that explains, "by adding just 4 lines of code, the Packaging & Deployment
> Wizard and Setup1.vbp can be easily modified to create Desktop shortcuts,
> as well as Start Menu shortcuts."
> http://www.freevbcode.com/ShowCode.asp?ID=3650
> I was wondering how this looked to people here, and if there are other
> approaches that might be better.

I didn't follow the links, but I want to urge you to ASK the user for
permission to install a shortcut onto the desktop. I personally despise
installers that do this without asking, and have actually denied everyone
the ability to create files/folders and/or write data to both my personal
and the All Users desktop.

If you don't ask for permission (due to technical reasons--or just plain
laziness), please make sure that your installer doesn't FAIL simply because
it can't create a shortcut; just report an error and move along. The only
thing worse than not asking permission is acting like that desktop shortcut
is the most important thing in the world. (And believe me, there are
installers out there like that.)
Author
7 Sep 2010 8:11 PM
Mike S
On 9/7/2010 8:50 AM, Jeff Johnson wrote:
Show quoteHide quote
> "Mike S"<ms***@yahoo.com>  wrote in message
> news:i61k16$sjp$1@news.eternal-september.org...
>
>> I want to modify the installer to create a desktop shortcut when a program
>> is installed. I found this discussion
>> http://www.vbforums.com/showthread.php?t=451311
>> that explains, "by adding just 4 lines of code, the Packaging&  Deployment
>> Wizard and Setup1.vbp can be easily modified to create Desktop shortcuts,
>> as well as Start Menu shortcuts."
>> http://www.freevbcode.com/ShowCode.asp?ID=3650
>> I was wondering how this looked to people here, and if there are other
>> approaches that might be better.
>
> I didn't follow the links, but I want to urge you to ASK the user for
> permission to install a shortcut onto the desktop. I personally despise
> installers that do this without asking, and have actually denied everyone
> the ability to create files/folders and/or write data to both my personal
> and the All Users desktop.
>
> If you don't ask for permission (due to technical reasons--or just plain
> laziness), please make sure that your installer doesn't FAIL simply because
> it can't create a shortcut; just report an error and move along. The only
> thing worse than not asking permission is acting like that desktop shortcut
> is the most important thing in the world. (And believe me, there are
> installers out there like that.)

Yes that is good advice. I decided to try Inno setup, I now have a
script that does the installation and includes checkboxes to optionally
let the user install desktop or shortcut icons.
Author
7 Sep 2010 8:31 PM
Mike S
<snip>
> Yes that is good advice. I decided to try Inno setup, I now have a
> script that does the installation and includes checkboxes to optionally
> let the user install desktop or shortcut icons.

Sorry, that should read optionally let the user install desktop or quick
launch icons. Innosetup is really impressive.
Author
7 Sep 2010 9:26 PM
Kevin Provance
"Mike S" <ms***@yahoo.com> wrote in message
news:i667ed$rru$2@news.eternal-september.org...

: Sorry, that should read optionally let the user install desktop or quick
: launch icons. Innosetup is really impressive.

And the price is certainly a bonus.  Not to mention if one understands
Delphi, the source can be reviewed.