• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 737
  • Last Modified:

Send URL Shortcut by mail WITH CUSTOMIZED ICON

I made this web form for our company for customers to fill in orders online whenever they please. For this I have created a URL link that goes directly to the form (obviously) and I made it a shortcut on my desktop. Now I wanted it to be more than a simple URL for our customers so I created our logo in .ICO format so that it could be a URL shortcut with our logo as the showing icon. I then tried to send it by mail to on of my collegues - now on trial no. 47 and still with no hope. The problem is that the .ICO does not seem to come with. Instead it shows this empty logo icon which is kind of sad.

I have tried to compress both files in one rar file with no result. I have searched through google but only found GPO which is not applicable here since I am trying to send it to other customers who are not in our network.
0
Mustafa Mazin Abdul Hameed
Asked:
Mustafa Mazin Abdul Hameed
  • 18
  • 13
1 Solution
 
GaryCommented:
If you mean a shortcut that they can save on their desktop then you can't just do that, they would have to save the ICO file.
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Can you please show the shortcut and icon?

You will need to send it via "EE-Stuff.com". Once you log in to that site, select the "Expert Area" Tab and then upload the icon and let me know the desired hyperlink as well. The system will give you a link which then advise me.
I can then obtain what I am after through that link.

I suspect that the reference in the link is pointing to a "local" file on your machine which of course does not exist on the remote machine. The icon must be sent and installed on the remote machine (or an accessible storage point to the remote machine) for the icon to work.

It seems a bit unclear, but once you send it to me, it may make things much clearer.

Thanks

Chris (Melbourne-Australia)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I have found a way you can do this without having to send any files to your clients.

1. On your website save a copy of the icon file (the name will end with extension
    "ico") to the root directory of your site but name it "favicon.ico"
    (which stands for "Favourite Icon")
2.  When a browser navigates to an address, it always checks for the presence  of a file under that name in the root of the site and if it finds it, it will display the icon just in front of the web address which has been typed into the browser, instead of using the default icon supplied by the browser.
3. If a user visiting the page LEFT clicks on the small icon which is then showing before the address of the page and drags that icon to their taskbar, they can pin the icon to the taskbar (which is handy) BUT an added bonus is they can also drag it to their desktop (not doumented)!
The icon will be copied to their desktop with the hyperlink of the page already embedded!

Note that not all browsers may work this way. Internet Explorer certainly does (as does Firefox, I believe, and many others. I use Maxthon, which seems to not have that inbuilt, but I will follow up with them to see if they can incorporate that in their next release.

So there you have it! :-) Every page on your site will then have the icon, and depending on which page is displaying, a user can drag the icon (with the currently showing web-page address) to their desktop.

All you need to do is advise the user how to set up their icon.
(I suggest putting a video link on your webpage and make a small video
on how to do this advise using to "click this link to learn how to create s shortcut to this page").

Does this solve your problem?
0
What Security Threats Are We Predicting for 2018?

Cryptocurrency, IoT botnets, MFA, and more! Hackers are already planning their next big attacks for 2018. Learn what you might face, and how to defend against it with our 2018 security predictions.

 
Mustafa Mazin Abdul HameedAuthor Commented:
hey guys, I am really appreciative for the comments but I am extremely busy at the moment, I will get back with you in a few days to let you know whether or not it worked :D
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
No problems.  :-)
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
hey, I uploaded the file and the direct link is https://filedb.experts-exchange.com/incoming/ee-stuff/8377-Saibini-Order-Form.url for the url
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Thanks MustafaMazin.

I don't really need the download thropugh EE-Stuff now, since my subsequent comment to the request to arrange the download really solves your problem.
(Not a waste of time though because it reminded me how to use "EE-Stuuf"    :-)

Have you tried out the solution I gave under ID: 40295657 (above)?

Cheers
Chris
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
Im not in the office right now but what your suggestion require is the webpage to be owned by me right?

In that case I dont know whether that would work because we are using smartsheet (an external webpage) for our orders.

Maybe I can talk with them if there is no way around this :)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
If you advise me the URL that users clickon I can look at it further, but you are right, if the external supplier cannot include the icon on their page to which the user links, then this method will not work.

I think this is the only way you can solve your problem unless you physically send the icon file to your cients (messy). Also I don't think users would bother the mucking around to set up the icon on their desktop. They would simply use a default icon and create the shortcut on their desktop which links to the URL you supply.

It should be easy for the forms supplier to do a fix on the icon on their forms page (since it forms part of the HTML code on their forms page). Of course if their "setuo" procedure for the forms is automated already (which it probably is) that could involve them having to change their automation program and they may be unwilling to do that.

Anyway, for the time being please advise the URL and I will see if there is some other way (but I doubt it).
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
sure thing, https://app.smartsheet.com/b/form?EQBCT=095eb73bf68e4b7289e3317bc5a2c39d

the icon on the top right corner is the one I have made an ICO file of.

Let me know whatever conclusion you have :)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Thanks. Another option we could have is for you to send via EE-Stuff the icon file you have prepared and I will see if I can whip up a small "installation program" which you can send to a client which will automatically place the icon plus its designated hyperlink onto a clients desktop. Your clients may be more willing to do that that try and muck around with setting up the icon themselves. (If they are not technical they would find that "too hard").

Of course,I am assuming that your clients are Windows based. I don''t think I could do anything that installs on a MAC or another platform.

Even if you do not like this last option, please send the icon you have in case it is needed for any other workaround.

Cheers
Chris
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
Yes I am assuming that also, so if that could work you have truly been a valuable asset to our company although the knowlegde i am getting from this is already valued :)

I have uploaded the ICO file direct link is https://filedb.experts-exchange.com/incoming/ee-stuff/8378-Kasturi-Group-Logo-13.ico

Now I am just asking so it is only a yes/no question (wouldnt want you to work too hard on this only) but is it possible to make that work on smartphones also? If not all of them then which OS if possible?
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I am not sure about smartphones as yet.  

I am on the verge of something for desktops. It would involve you advising your client to download and execute a simple executable file which is obtainable from a link on your website.
This executable which will simply create your icon on their desktop pointing to the webpage you have designated.

Would you want the application to be able to produce different shortcuts (with different icons) icons for different forms or just this one form and icon? If so, I can also then produce an "admin" version of the program which you woulduse to producedifferent icons with assocuated different pages.

The only thing you would need to produce is different icon (.ico) files.
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
I am making a form for each client so it would mean the world to me if I had the opportunity to determine the link the icon should direct towards.

Is it possible for you to teach me this in a simple way or does it require some sort of java programming background?
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I am using VB.Net. The code is simple and I have actually written in four/five lines the code to get it to the desktop (and it links to the website), but the icon bit is tricky.

I have spent about 5 houtrs on this now, and it is 2.11am, so may I please go to bed and get some shut-eye?
I will resume tomorrow (today)

OK?

Cheers
Chris (Melbourne-Australia)
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
dude, of course I am not even asking you to do anything, this is not what I became a member for. I though you only where to advise, not to produce, so you do whatever you feel, if anything just give me a youtube link that describes what I need to do :)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Stand by...very close.

Chris
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Ok...All finished and I think it works OK.

I have uploaded the installation program to the following link:
https://filedb.experts-exchange.com/incoming/ee-stuff/8379-MakeShortcut.zip

What basically happens is that you install the program (by unzipping and then running "setup.exe") and the first time it runs it will ask you for a "Shortcut configuration" file (*.scut). You should ignore that first request and simply close the application.

I am not sure if it installs an icon on your desktop (I asked it to, but I am not sure if that is working yet).
If it is there, all well and good, otherwise click the "Start" button on your PC Toolbar and type in "makeshortcut" (don't press <Enter>) the program should appear and then when you click on it, the program should run.

To create a "shortcut configuration file" simply type in "new" in the File Dialogue which appears and asks for a configuration file. The Configuration panel should then appear. You then simply type in the "Target" for your shortcut (in your case the web address for the form), the name of the shortcut ("Order Form") and then click on the "Icon File" button and select the Icon file you which want to use. Do not worry that the pathway showing will probably not exist on the users PC . The program is only interested in the actual filename, not the path.

Click "Process" and everything should then be automatic, with a "Configuration file created" message.
The program will then ask if you want to create the shortcut now? (In case you want to test it).
(Select "Yes" since we will test to see if all is OK). (When you get more confident you probably will not bother).

The icon should then appear on your desktop, and when you double-click you will be taken to the desired target (website).

It was created under version v4.0 of the .NETFramework so I assume users will need that when they run theprogram (although I suspect it will install it if they do not have it on board, after seeking their permission.)

You need to supply the program files (all the ones I have supplied to you in the zip file) to your clients. They have the same instructions, but there is no need to mention "new" for creation of new configuration files, since they do not really need that functionality. (I assume)

I have not written any help file (sorry), but can do so if you wish.

When the program runs for your customers, it will fist ask them to load the "configuration file" (*.scut), so you will need to supply that to them as well. The program will then also ask for the icon file, so you need to send that to them.  If the program cannot find the icon file on startup it will ask the user to locate it.
(it will know the correct name from the configuration file it has just read in).
Once they locate the icon file, the shortcut will be created and the program will close.

I have ensured that every time anyone runs the program (they only need to install once) it remembers where the "scut" and "ico" files were last located, and will start at those folders.

Tell users to keep both the configuration files and the icon files in the same folder so that next time they will be easier to locate.

The code (which probably needs cleaning up and a few more comments) follows.
It is written in VB.Net as a Forms application. I could have written it a command line application but that might have been a bit trickier.

 In summary: supply them with the "zip" installation file, a "scut" file that you have created for them for theirparticular desktop shortcut and the actual ".ico" file you have created for them, Ask them to put the ".scut" file and the ".ico"  files in a common folder and then ask them to run the program and follow your supplied instructions (which will be similar to mine here).

I hope it works for you....I am sorry, but I cannot see how I can write it for MAC/Ipad/Phones.
Maybe the users can create the icon on a PC and somehow copy them across on to a different platform (not sure if that would work, though...let me know if it does  :-)

I am looking forward to hopefullysolving yyour problem.

As usual all the code is public domain and can be tweaked as anyone wishes.

Cheers

Chris
(Melbourne-Australia)

Module: Main.vb
Imports IWshRuntimeLibrary

Module MakeShortcut
    Public Sub main()
        With Form1.openFileDialog1
            .FileName = "*.scut"
            .Filter = "MakeShortCut configuration file|*.scut"
            If My.Settings.ConfigDir = "" Then
                My.Settings.ConfigDir = "C:\"
            End If
            .InitialDirectory = My.Settings.ConfigDir
            .Title = "Load which configuration file?"
            .CheckFileExists = False 'we need this in case we type in "new" to create an icon configuration file
            .ShowDialog()
            If Strings.Right(.FileName.ToLower, 8) = "new.scut" Or _
                Strings.Right(.FileName.ToLower, 3) = "new" Then
                Form1.ShowDialog()
            Else
                If FileIO.FileSystem.FileExists(.FileName) Then
                    ReadConfigFile(.FileName)
                    Create_ShortCut(My.Settings.TargetPath, "Desktop", My.Settings.ShortCutName, My.Settings.IconFileName)
                    MsgBox("Desktop shortcut created")
                    End
                Else
                    MsgBox("That file does not exist!" + vbCrLf + .FileName)
                End If
            End If
        End With
    End Sub
    Private Sub ReadConfigFile(sFile As String)
        Try
            ' Create an instance of StreamReader to read from a file. 
            ' The using statement also closes the StreamReader. 
            Using sr As System.IO.StreamReader = New System.IO.StreamReader(sFile)
                Dim sLine As String
                ' Read lines from the file until the end of  
                ' the file is reached. 
                sLine = sr.ReadLine()
                My.Settings.TargetPath = sLine
                sLine = sr.ReadLine()
                My.Settings.ShortCutName = sLine
                sLine = sr.ReadLine()
                If Not (FileIO.FileSystem.FileExists(sLine)) Then
                    Form1.GetIconFile()
                Else
                    My.Settings.IconFileName = sLine
                End If
                My.Settings.Save()
            End Using
        Catch e As Exception
            ' Let the user know what went wrong.
            MsgBox("The configuration file could not be read:" + vbCrLf + e.Message)
        End Try
    End Sub

    Public Function Create_ShortCut(ByVal sTargetPath As String, ByVal sShortCutPath As String, ByVal sShortCutName As String, _
                                    ByVal sIconPath As String) As Boolean

        ' Requires reference to Windows Script Host Object Model
        Dim oShell As New IWshRuntimeLibrary.WshShell
        Dim oShortCut As IWshRuntimeLibrary.WshShortcut
        Try
            sShortCutPath = oShell.SpecialFolders.Item(sShortCutPath) & "\" & sShortCutName & ".lnk"

            oShell = New IWshRuntimeLibrary.WshShell
            oShortCut = oShell.CreateShortcut(sShortCutPath)
            With oShortCut
                .TargetPath = sTargetPath
                .IconLocation = sIconPath
                .Save()
            End With
            oShortCut = Nothing : oShell = Nothing
            Return True
        Catch e As Exception
            ' Let the user know what went wrong.
            MsgBox("The configuration file could not be created:" + vbCrLf + e.Message)
            Return False
        End Try
    End Function

End Module

Open in new window


Module: Form1.vb
' ********************************************************************************
'     Document    :  Form1.vb
'     Description :  This form is the only one in the application.
'                    The creator of the configuration files defines the files 
'                    via this form.
'                    Users will not normally see it. To make it appear you need
'                    to type "new" or "new.scut" in the OPenFileDialog which appears
'                    when the program is first run.
' ********************************************************************************
Public Class Form1

    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        End
    End Sub

    Private Sub btnProcess_Click(sender As System.Object, e As System.EventArgs) Handles btnProcess.Click
        If Me.txtTargetPath.Text.Length > 0 And _
            Me.txtShortCutName.Text.Length > 0 And _
            Me.txtIconFile.Text.Length > 0 Then
            My.Settings.ShortCutName = txtShortCutName.Text
            My.Settings.TargetPath = txtTargetPath.Text
            My.Settings.IconFileName = txtIconFile.Text
            My.Settings.Save()
            saveFileDialog1.CheckPathExists = True
            saveFileDialog1.Title = "Save Configuration to which file?"
            saveFileDialog1.OverwritePrompt = True
            saveFileDialog1.Filter = "MakeShortCut Config files (.scut)|*.scut"
            saveFileDialog1.FileName = "*.scut"
            saveFileDialog1.InitialDirectory = System.IO.Path.GetFullPath(txtIconFile.Text)
            saveFileDialog1.ShowDialog()
            If saveFileDialog1.FileName <> "" And saveFileDialog1.FileName <> "*.scut" Then
                WriteFilename(saveFileDialog1.FileName)
                MsgBox("Configuration written to: " + My.Settings.ShortCutName + ".scut")
                If MsgBox("Do you want to create the Shortcut now?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then
                    If Create_ShortCut(My.Settings.TargetPath, "Desktop", My.Settings.ShortCutName, My.Settings.IconFileName) Then
                        MsgBox("Shortcut created")
                    End If
                End If
            End If
        Else
            If Me.txtTargetPath.Text.Length = 0 Then
                MsgBox("Please define a Target Path")
            Else
                If Me.txtShortCutName.Text.Length = 0 Then
                    MsgBox("Please define a Shortcut Name")
                Else
                    MsgBox("Please select an Icon file")
                End If
            End If
        End If
    End Sub
    Private Sub WriteFilename(sFileName As String)
        Using sw As System.IO.StreamWriter = New System.IO.StreamWriter(sFileName)
            sw.WriteLine(My.Settings.TargetPath)
            sw.WriteLine(My.Settings.ShortCutName)
            sw.WriteLine(My.Settings.IconFileName)
        End Using
    End Sub
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Me.txtTargetPath.Text = My.Settings.TargetPath
        Me.txtShortCutName.Text = My.Settings.ShortCutName
        Me.txtIconFile.Text = My.Settings.IconFileName
    End Sub

    Private Sub btnIconFile_Click(sender As System.Object, e As System.EventArgs) Handles btnIconFile.Click
        GetIconFile()
    End Sub
    Public Sub GetIconFile()
        With openFileDialog1
            .InitialDirectory = My.Settings.InitDir
            If .InitialDirectory = "" Then
                .InitialDirectory = "C:\"
            End If
            .CheckFileExists = True
            .Filter = "Icon Files(.ICO)|*.ico"
            .FileName = System.IO.Path.GetFileName(My.Settings.IconFileName)
            .Title = "Please locate icon file " + System.IO.Path.GetFileName(My.Settings.IconFileName)
            .ShowDialog()
            If openFileDialog1.FileName.Length > 0 Then
                txtIconFile.Text = openFileDialog1.FileName
                My.Settings.InitDir = System.IO.Path.GetFullPath(txtIconFile.Text)
                My.Settings.IconFileName = openFileDialog1.FileName
                My.Settings.Save()
            End If
        End With
    End Sub
End Class

Open in new window

0
 
Mustafa Mazin Abdul HameedAuthor Commented:
Hey,

I really appreciate your work seems like this has taken a lot of time!

However, this is the message i get when i try to open either file (setup or makeshortcut) (untitled png file). The note that comes up after cklicking in details is the uploaded file called IP13KOY1.log

Im pretty sure that i installed netframework 4.5, and the link is purple when i do a google search in netframework so im pretty sure, but how can i be certain?
IP13KOY1.log
Untitled.png
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
I have recompiled and adjusted the security settings (in case this is the problem).

Download afresh from:
https://filedb.experts-exchange.com/incoming/ee-stuff/8385-SetupMakeShortcut.ziphttps://filedb.experts-exchange.com/incoming/ee-stuff/8377-Saibini-Order-Form.url
https://filedb.experts-exchange.com/incoming/ee-stuff/8378-Kasturi-Group-Logo-13.ico
https://filedb.experts-exchange.com/incoming/ee-stuff/8379-MakeShortcut.zip
https://filedb.experts-exchange.com/incoming/ee-stuff/8380-MakeShortcut.zip


Might be an uidea to turn off your virus checker in case that is causing a problem (trust me, there is no virus)  :-)

Have a read of the following article which covers the problem:
http://codeketchup.blogspot.com.au/2013/06/how-to-fix-deployment-and-application.html

To see whether you have V4 of framework installed, go into the registry editor by clicking on the "Start" button and typing "RegEdit" then press enter

BE CAREFUL NOT TO CHANGE ANY VALUES IN THIS EDITOR!

Starting from the top of the "tree", expand "HKEY_LOCAL_MACHINE"
Then expand "SOFTWARE"
Then Expand "Microsoft"
Then expand ".NETFramework"

Folders will appear, some of which have numbers in them showing versions.
Mine show as the following:

Screen capture of Regedit keys for .NetFramework
From this I can see I have version 2,3 and 4 installed. (You don't need them all,)

If you do not have version 4 installed you need to install it by going to:
http://www.microsoft.com/en-us/download/details.aspx?id=17851

Let me know how itgoes  

Cheers
Chris
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
Thank you, I have all netframeworks installed just like you.

I uploaded the message it says after I load the configuration and logo fil. The configuration file I assume is the URL and the logo file I assume is the ICO file.

If not please correct me. There is no log option (details) when I click ok - just another window saying 'a shortcut was created on your desktop'..
Untitled.png
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
No, what you saw was what the user sees.

You have to create the configuration file first. That is why I said in my instructions that you ignore that first file dialogue which asks you for a configuration file.

To create the configuration file you type "new" where the filename shows in that panel. It will then ask you for the "Target" (which is the URL of the webpage) and the name of the shortcut (for our first go it will be "Order Form") and then load the icon file file from your PC.

Then click "Process" and it will create the configuration file and ask where to store it. (The file ends in an extension of ".scut").

THEN you repeat what you just did after installation, loading the newly created configuration file. The program should then say that the shortcut has been created. Check on your desktop and click on it to see where it takes you.

Please re-read and follow my original instructions (which i have summarised here). It sounds like everything will eventually work!  :-) The original instructuions tell you what you need to supply to the end user.

Let me know how you go. If you have further problems I will create a video tutorial for you.

Cheers
Chris
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
IT WORKS!!

You sir are a true magician!

But now I have one last problem

The file cant be shared, Although the reciever has netframework installed it only shows up as either form[1] or as a "ink" file fx order form.ink in which it dont know how to open (dependent on which file I send)

Should the reciever also have the program you developed or is there somehting I am doing wrong again ?
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
As I mentioned in the instructions, you need to send the following to the user:

      1. The program just as I sent to you via the link
      2. The ".scut" file that you have created for him/her
      3. The "ico" file that you already have

 The user then places them all in the same directory (it can be the folder to which he/she has downloaded the
 files). The user then runs the program and it will ask for the ".scut" file and the icon file (just like you did by
  mistake the first  time).

 The only difference between his/her actions and yours is that a ".scut" filoe is being loaded (instead of the
  word "new").

  Is that too complicated do you think for the end user? (I can create a tutorial if you like).

Cheers
Chris
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
It worked like a charm!!

Thank you very much my good sir, now I have one last request.

Because the answer to your last question is yes. I mean even if it isn't too complicated for some of our customers we must assume that most of them don't have the necessary skills to perform this task on their own. Therefore I would like you to tell me how I can do a proper uninstall of the program so that I can make the installation video for our customers (fx, now it doesnt even aks for ICO file, and setup file tells me its already installed making it difficult for me to do a proper video)

I don't want you to do anymore for me, I am truly grateful already :))
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Sorry for the delay...lots of work on my plate at the moment (I look after two websites).

I will actually create an Install and Uninstall module for you which should cover everything.
(It will be an interesting exercise forme too)

By the way, when I ran the program just a moment ago and typed in "new" externally to the programming environment I received an error message "New" cannot be found. Did you have that problem? It may just be an environmental problem on my PC. A workaround would be for me to just produce a seperate small program (a clone of the current one) called "MakeNewShortcut" which you would run (and not distribute to the client). The existing application would then go to the clients. What do you think?

I had great ideas about allowing you to browse to a website to select the URL (I gather you would not be using this to link to files on a PC) but it is becoming just a little too much (time wise), so I decided against it. You will just have to type in the web page URL manually (I hope that is OK)  :-)

Stand by...I am working on the installer/uninstaller but it may be a day or two.

Cheers
Chris (Melbourne, Australia)
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Am still coming to grips with the deployment package creation. I have tried "WIX" which is supposed to be terrific (Microsoft use it), but it is rather complex and has some errors in it's documentation which I cannot get around.

 I already own "Inno" but again this is my first VB.Net deployment so I am not sure which files to use in the deployment package.

After spending some time on those two, it came down to the freely available InstallShield "Lite" which is available to all Visual Studio programmers and seems the easiest to use. I just have to work out exactly what files to include in the deployment package and I will then upload to "EE-Stuff" and let you know what you need to do.  Stand by....
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
Blast! I just spent the last hour writing out this comment and after
I switched to another webpage, I lost everything! (I hate that!)

Here we go again!....(LOL) I am writing it all in notepad first and
will then copy/paste...lesson learned!

I have finished everything for you now.

I ended up using "InstallShield Lite" for my Disbursement
program (the process that creates the install and uninstall
executables). since it comes with "Visual Studio 2010"
(which I am using) and later editions....and it is free!

Although I had previously purchased "Inno Setup" which was great
with VB6, it is a little too messy when using Visual Studio (and is
not built in to the interface).
I also tried what Microsoft uses (WIX) it is too complicated and
probably more suited for big projects. It produces "MSI" files for
installation instead of "EXE" files and is very suitable for
different platforms.

You can obtain the "Setup" file named "SetupMakeShortcut.exe" from
the following link:
https://filedb.experts-exchange.com/incoming/ee-stuff/8385-SetupMakeShortcut.zip

Now, there are only three things you need to supply to the end user:
      1. The Installation file "SetupMakeShortcut.exe"
      2. "Configuration" file(s) you have created using the program
         "MakeShortcut"
      3. Icon file(s) associated with the configuration file(s)

The users download the files (or you can send them via email if you
wish). The "SetupMakeShortcut.exe" file is 2MB in size, but if you zip it
using PKZip or some other compression program
 (as I have done in the download you will are making from EE-Stuff)
it compresses to 995K. The end  users will then need to unzip any
zipped filed before running using them.

When the users run the installation (or "setup") program, the
program "MakeShortcut" will be installed in their machines stored in
either "C:\Program Files\MakeShortcut" or
         "C:\Program Files (X86)\MakeShortcut" depending on what
type of operating system they are running (XP, Windows 7 or Windows 8).
At the moment (I think) it is not suitable for telephones or MACS
but should run on tablets running under Windows 8 (on the desktop).

The installation creates two icons, one named "MakeShortcut" with a
distinctive green icon, and one named "Uninstall MakeShortcut".

Before closing, the installation program gives users the option of
running "MakeShortcut" immediately after the installation program
closes. The users can opt to not do so by "un-ticking" the option
showing in the final panel of the installation program. Let's assume
they have "un-ticked" the option.

When the users decide they want to install a shortcut supplied by
your good selves, they will click on the "MakeShortcut" desktop icon
and a dialog box will open asking them to load a configuration file
(one of the ones you supplied).

(This will also happen at your end when you run it, but you type "new"
for the file name so that you can <b>create</b> a configuration file
rather than load one).

That configuration file they load should be in the folder where the users
stored the download files (or the files attached to your email as
the case may be)

(I am saying "users" each time to avoid the required "him/her", or
"she/him" which would follow if I used a singular term).

The program will then ask the users to locate the icon file named in
the loaded configuration file (again probably stored where the
configuration file was stored).

If the icon is correctly located the program will then create a
desktop shortcut to the designated target in the configuration file,
using the supplied icon.

The created shortcut will appear on the user's desktop and a message
"Shortcut Created" will show. The "MakeShortcut" program will then
close.

If users want to create a second desktop shortcut using the program,
they will need to click on the "MakeShortcut" icon again.

To uninstall the program users have two options.They can either
click on the "Uninstall MakeShortcut" icon on their desktop, or
perform the normal program uninstall via the Control Panel.

I personally don't like having the "uninstall" icon on the desktop
in case I accidentally click it (although it will confirm with the
user before uninstalling). It just takes up space, and I would be
unlikely to uninstall teh program for a while, if I envisaged
several shortcut configurations to come from you.

When uninstalling, the created shortcuts themselves do not disappear
(of course), only the two "MakeShortcut" and "Uninstall
MakeShortcut" icons are removed
(as well as the installed program,of course).

The amended code (only slightly amended to fix a couple of problems
I found) is listed below.

I hope this meets all your requirements (it was a great exercise for
my mind and helped me learn a lot more about deployment of packages).

As stated before, I will willingly produce a video on how to install
and run the program if you wish. Just let me know.

Cheers
Chris  
         
' ********************************************************************************
'     Document    :  Main.vb
'     Description :  The starting point for the "MakeShortcut" program
' ********************************************************************************
Imports IWshRuntimeLibrary

Module MakeShortcut
    Public Sub main()
        LoadConfigurationFile()
    End Sub

    Public Sub LoadConfigurationFile()
        LoadConfigForm.Show() 'this form has an opacity setting of 0% so is invisible to the user, but it allows you to 
        '                      correctly display the "OpenFileDialog" in the centre of the screen
        '                                    
        With LoadConfigForm.openFileDialog1
            .FileName = "*.scut"
            .Filter = "MakeShortCut configuration file|*.scut"

            If My.Settings.ConfigDir = "" Then
                My.Settings.ConfigDir = "C:\"
                'should save settings after storing new values therein
                My.Settings.Save()
            End If
            .InitialDirectory = My.Settings.ConfigDir
            .Title = " Load which configuration file?"
            .CheckFileExists = False 'we need this in case we type in "new" to create an icon configuration file
            .ValidateNames = True
            Dim ButtonClicked As DialogResult = .ShowDialog()
            If ButtonClicked <> DialogResult.Cancel Then
                If .FileName <> "*.scut" Then

                    If Strings.Right(.FileName.ToLower, 8) = "new.scut" Or Strings.Right(.FileName.ToLower, 3) = "new" Then

                        'if the user enters "new" (in upper/lower/mixed case)
                        'we are going to create aconfiguration file instead of loading one
                        Form1.ShowDialog()

                    Else

                        If FileIO.FileSystem.FileExists(.FileName) Then
                            ReadConfigFile(.FileName)
                            Create_ShortCut(My.Settings.TargetPath, "Desktop", My.Settings.ShortCutName, My.Settings.IconFileName)
                            MsgBox("Desktop shortcut created")

                        Else
                            MsgBox("That file does not exist!" + vbCrLf + .FileName)
                        End If

                    End If

                End If

            End If

        End With
        End
    End Sub

    Private Sub ReadConfigFile(sFile As String)

        Try
            ' Create an instance of StreamReader to read from a file. 
            ' The using statement also closes the StreamReader. 
            Using sr As System.IO.StreamReader = New System.IO.StreamReader(sFile)

                Dim sLine As String
                ' Read lines from the file until the end of  
                ' the file is reached. 
                sLine = sr.ReadLine()
                My.Settings.TargetPath = sLine
                sLine = sr.ReadLine()
                My.Settings.ShortCutName = sLine
                sLine = sr.ReadLine()

                If Not (FileIO.FileSystem.FileExists(sLine)) Then

                    Form1.GetIconFile()

                Else
                    My.Settings.IconFileName = sLine
                End If
                'should save settings after storing new values therein
                My.Settings.Save()
            End Using

        Catch e As Exception
            ' Let the user know what went wrong.
            MsgBox("The configuration file could not be read:" + vbCrLf + e.Message)
        End Try

    End Sub

    Public Function Create_ShortCut(ByVal sTargetPath As String, _
                                    ByVal sShortCutPath As String, _
                                    ByVal sShortCutName As String, _
                                    ByVal sIconPath As String) As Boolean

        ' Requires reference to Windows Script Host Object Model
        Dim oShell As New IWshRuntimeLibrary.WshShell
        Dim oShortCut As IWshRuntimeLibrary.WshShortcut

        Try
            sShortCutPath = oShell.SpecialFolders.Item(sShortCutPath) & "\" & sShortCutName & ".lnk"

            oShell = New IWshRuntimeLibrary.WshShell
            oShortCut = oShell.CreateShortcut(sShortCutPath)
            With oShortCut
                .TargetPath = sTargetPath
                .IconLocation = sIconPath
                .Save()
            End With
            oShortCut = Nothing : oShell = Nothing
            Return True

        Catch e As Exception
            ' Let the user know what went wrong.
            MsgBox("The configuration file could not be created:" + vbCrLf + e.Message)
            Return False
        End Try

    End Function

End Module

Open in new window


' ********************************************************************************
'     Document    :  Form1.vb
'     Description :  This form is the only one in the application.
'                    The creator of the configuration files defines the files 
'                    via this form. It appears when the creator types "new" in the 
'                    "load configuration file" dialog.
' ********************************************************************************
Imports CKRCustomMessageBox
Imports System.Windows

Public Class Form1
    Dim WithEvents myFM As New System.Windows.Forms.OpenFileDialog

    Private Sub BtnClose_Click(sender As System.Object, _
                              e As System.EventArgs) _
            Handles btnClose.Click
        If MsgBox("Load another Configuration file?", vbQuestion + vbYesNo) = vbNo Then
            Application.Exit()
        Else
            LoadConfigurationFile()
        End If
    End Sub

    Private Sub btnProcess_Click(sender As System.Object, _
                                 e As System.EventArgs) _
            Handles btnProcess.Click

        If (Me.txtTarget.Text.Length > 0) And (Me.txtShortCutName.Text.Length > 0) And (Me.txtIconFile.Text.Length > 0) Then
            My.Settings.ShortCutName = txtShortCutName.Text
            My.Settings.TargetPath = txtTarget.Text
            My.Settings.IconFileName = txtIconFile.Text
            My.Settings.Save()
            saveFileDialog1.CheckPathExists = True
            saveFileDialog1.Title = "Save Configuration to which file?"
            saveFileDialog1.OverwritePrompt = True
            saveFileDialog1.Filter = "MakeShortCut Config files (.scut)|*.scut"
            saveFileDialog1.FileName = "*.scut"
            saveFileDialog1.InitialDirectory = System.IO.Path.GetFullPath(txtIconFile.Text)

            If FileIO.FileSystem.FileExists(txtIconFile.Text) Then
                Dim result = saveFileDialog1.ShowDialog()

                If result <> Windows.Forms.DialogResult.Cancel Then

                    If saveFileDialog1.FileName <> "" And _
                        Strings.InStr(saveFileDialog1.FileName, "*") = 0 And _
                        FilenameIsOK(saveFileDialog1.FileName) Then
                        WriteFilename(saveFileDialog1.FileName)
                        MsgBox("Configuration written to: " + saveFileDialog1.FileName)

                        If MsgBox("Do you want to create the Shortcut now?", vbQuestion + vbYesNo + vbDefaultButton2) = vbYes Then

                            If Create_ShortCut(My.Settings.TargetPath, "Desktop", My.Settings.ShortCutName, My.Settings.IconFileName) Then
                                MsgBox("Shortcut created")
                            End If

                        End If
                        If MsgBox("Load another Configuration file?", vbQuestion + vbYesNo) = vbNo Then
                            Application.Exit()
                        Else
                            LoadConfigurationFile()
                        End If
                    Else
                        If Me.txtTarget.Text.Length = 0 Then
                            MsgBox("Please define a Target Path")

                        Else

                            If Me.txtShortCutName.Text.Length = 0 Then
                                MsgBox("Please define a Shortcut Name")

                            Else
                                MsgBox("Please select an Icon file")
                            End If

                        End If

                    End If

                End If
            Else
                MsgBox("Icon file does not exist!" + vbCrLf + txtIconFile.Text)
            End If
        End If
    End Sub
    
    Public Shared Function FilenameIsOK(ByVal fileNameAndPath As String) As Boolean

        Dim fileName = System.IO.Path.GetFileName(fileNameAndPath)
        Dim directory = System.IO.Path.GetDirectoryName(fileNameAndPath)

        For Each c In System.IO.Path.GetInvalidFileNameChars()

            If fileName.Contains(c) Then
                Return False
            End If

        Next

        For Each c In System.IO.Path.GetInvalidPathChars()

            If directory.Contains(c) Then
                Return False
            End If

        Next

        Return True
    End Function

    Private Sub WriteFilename(sFileName As String)
        Using sw As System.IO.StreamWriter = New System.IO.StreamWriter(sFileName)
            sw.WriteLine(My.Settings.TargetPath)
            sw.WriteLine(My.Settings.ShortCutName)
            sw.WriteLine(My.Settings.IconFileName)
        End Using
    End Sub
    Private Sub Form1_Load(sender As System.Object, _
                           e As System.EventArgs) _
            Handles MyBase.Load
        Me.txtTarget.Text = My.Settings.TargetPath
        Me.txtShortCutName.Text = My.Settings.ShortCutName
        Me.txtIconFile.Text = My.Settings.IconFileName
    End Sub
    Private Sub btnIconFile_Click(sender As System.Object, _
                                  e As System.EventArgs) _
            Handles btnIconFile.Click
        GetIconFile()
    End Sub

    Public Sub GetIconFile()
        With openFileDialog1
            .InitialDirectory = My.Settings.InitDir

            If .InitialDirectory = "" Then
                .InitialDirectory = "C:\"
            End If

            .CheckFileExists = True
            .Filter = "Icon Files(.ICO)|*.ico"
            .FileName = System.IO.Path.GetFileName(My.Settings.IconFileName)
            .Title = "Please locate icon file " + System.IO.Path.GetFileName(My.Settings.IconFileName)
            .ShowDialog()

            If openFileDialog1.FileName.Length > 0 Then
                txtIconFile.Text = openFileDialog1.FileName
                My.Settings.InitDir = System.IO.Path.GetFullPath(txtIconFile.Text)
                My.Settings.IconFileName = openFileDialog1.FileName
                My.Settings.Save()
            End If

        End With
    End Sub

   
End Class

Open in new window


 References required for a successful compilation of the code using
 the VB.NET compiler within Visual Studio 2010 (or above) are:

References used in the "makeShortcut" program
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
got it champ

and if it doesnt bother you further I would like to request the 'how-to' video :)
0
 
Mustafa Mazin Abdul HameedAuthor Commented:
This guy made a total new program from scratch, explained to me how to use it, shared the codes and offered to make a freaking how-to video for dummies!!!

If I could grad A+ I would!
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
No problems. Thanks for the points (I need them).

I will prepare the video in the next two days or so and let you know by leaving a message here.

Cheers
Chris
0
 
Chris Raisin(Retired Analyst/Programmer)Commented:
So about the dealy with the video. (I have been in and out of illness).
 Do you still want it?

Cheers
Chris
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 18
  • 13
Tackle projects and never again get stuck behind a technical roadblock.
Join Now