Silverfrost Forums

Welcome to our forums

Create a desktop icon / shortcut

4 Mar 2011 4:41 #7871

I was looking for a simple way to create a desktop icon for a program which I have installed just by copying the EXEs and DLLs into a new folder. May be that someone here can use it:

      subroutine create_vbs()

c     creates and runs a Visual-Basic-Script for a shortcut

      IMPLICIT NONE
      INCLUDE <WINDOWS.INS>

      integer*4      j
      character*256  path_1,path_2,string,getenv@
c
c     in this example, MYPROG is the name of the programme for which 
c     a desktop icon should be created
c
      path_1 = ' '
      path_2 = ' '
      path_1 = getenv@('USERPROFILE')
      path_2 = getenv@('PROGRAMFILES')
      call append_string@(path_2,'\\MYPROG')

      open(10,file='shortcut.vbs',err=900,status='unknown')
      write(10,'(A)',err=900)
     *  'Set oWS = WScript.CreateObject('WScript.Shell')'
      string = ' '
      string = 'sLinkFile = ''
      call append_string@(string,path_1)
      call append_string@(string,'\\DESKTOP\\MYPROG.LNK'')
      write(10,'(A)',err=900)string
      write(10,'(A)',err=900)
     *  'Set oLink = oWS.CreateShortcut(sLinkFile)'
      string = ' '
      string = 'oLink.TargetPath = ''
      call append_string@(string,path_2)
      call append_string@(string,'\\MYPROG.EXE'')
      write(10,'(A)',err=900)string
      write(10,'(A)',err=900)'oLink.Description = 'MYPROG''
      string = ' '
      string = 'oLink.IconLocation = ''
      call append_string@(string,path_2)
      call append_string@(string,'\\MYPROG.EXE, 0'')
      write(10,'(A)',err=900)string
      string = ' '
      string = 'oLink.WorkingDirectory = ''
      call append_string@(string,path_2)
      call append_string@(string,''')
      write(10,'(A)',err=900)string
      write(10,'(A)',err=900)'oLink.Save'
900   close(10)

      call cissue@('shortcut.vbs',j)

      open(10,file='shortcut.vbs',err=910,status='old')
910   close(10,status='delete')
      return
      end

Regards - Wilfried

4 Mar 2011 5:37 #7872

Wilfried,

Nice example.

Many users on the forum use an Installer program. The one I use is Jordan Russell Software's 'InnoSetup'. Google for InnoSetup or Jordan Russell and you'll find it. Even better is that it is freeware.

InnoSetup can be configured with a script so that it installs wherever you choose (e.g. in C:\Program Files\etc) and whether you want to do such things as install fonts, DLLs, icons (desktop, Start menu etc), shortcuts , file associations and other registry entries and so on. Really clever is that it can also install salflibc.dll for you, create folders, and copy example files. All of this is then packed up into a single EXE file, which unpacks itself when you run it. Since the Setup EXE file is a zipped type of file, it can be a lot smaller than you would think.

I recommend that you try it.

Regards

Eddie

Please login to reply.