Software Installer
Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
Hello,
Its been a while since I posted any application tutorials because its been hard coming up with new things to do and I know quite alot of you are having the same trouble thinking of things to do. I hope this tutorial will give you some ideas or at the very least its something to get your teeth into and play about with ;).
OK im going to show you how you can make your very own custom made software installer.
First thing you need to do is startup VB and open a new windows forms project. Then add a "Button" to your form and thats pretty much all you need on your form for this tutorial, that was easy.
Now we move onto the code and to start with we need to add a public variable to hold our folder name so add this directly below "Public Class Form1":
Then we are going to add a function that will do all the hard work for us so below the code you just added, add this entire code block:
Now inside your "Button1_Click" event add this code:
Then still in the "Button1_Click" event add this code aswell:
Now for the very important part that makes this whole thing work. Because this is an installer we obviously need to include our application and any files required. So locate your application folder (the application that you want to have installed) and add your Application.exe and any dlls, images, text files and anything else thats inside your application folder and add them ALL as resources into this project.
THIS IS IMPORTANT:
After you have added everything into resources you should see a new "Resources" folder in the solution explorer at the top-right of your screen like this:
![Image]()
You can see ive added my application and all the files that it needs as resources. Now once everything has been added you need to highlight/select ALL your resource files and take a look at the properties window directly below as seen in this image:
![Image]()
You need to change the "Build Action" propertie to "Embedded Resource" and then save your project.
Thats it your finished
you now have your very first custom made software installer.
I know it seems a bit basic just having 1 button but I did it this way so you can change/improve it to your own needs and requirements. You can add options to create shortcuts on the desktop and the start menu and even add status label or progress bar to show the installation progress and even add an uninstall feature.
I have added some of these features to the attached project file so you can get an idea of what you can do and just how easy it is ;).
Download: Happy coding cooll;
Its been a while since I posted any application tutorials because its been hard coming up with new things to do and I know quite alot of you are having the same trouble thinking of things to do. I hope this tutorial will give you some ideas or at the very least its something to get your teeth into and play about with ;).
OK im going to show you how you can make your very own custom made software installer.
First thing you need to do is startup VB and open a new windows forms project. Then add a "Button" to your form and thats pretty much all you need on your form for this tutorial, that was easy.
Now we move onto the code and to start with we need to add a public variable to hold our folder name so add this directly below "Public Class Form1":
Code: Select all
Change "My Application" to any name you like, this is going to be the name of our application folder into which our application will be installed.Public InstallFolder = "My Application"
Then we are going to add a function that will do all the hard work for us so below the code you just added, add this entire code block:
Code: Select all
All that code does is finds and extracts the resource file that we want. In our case its going to extract all our application files just like any other installer does but ill explain more about that further on. Private Function ExtractResources(ByVal Resource As String) As String
Dim ExtractFileTo As String = (My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\" & InstallFolder & "\") + Resource.Replace(Application.ProductName & ".", "")
Dim CheckFile As New System.IO.FileInfo(ExtractFileTo)
Dim SearchResourceFiles As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly()
Dim PrepareResource As System.IO.Stream = SearchResourceFiles.GetManifestResourceStream(Resource)
Dim bytesRead As Byte() = New Byte(PrepareResource.Length - 1) {}
PrepareResource.Read(bytesRead, 0, bytesRead.Length)
Dim SaveResource As New System.IO.FileStream(ExtractFileTo, System.IO.FileMode.Create)
SaveResource.Write(bytesRead, 0, bytesRead.Length)
SaveResource.Close()
Return ExtractFileTo
End Function
Now inside your "Button1_Click" event add this code:
Code: Select all
That code will create our application folder inside the windows "Program Files" directory, again just like any other installer.My.Computer.FileSystem.CreateDirectory(My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\" & InstallFolder & "\")
Then still in the "Button1_Click" event add this code aswell:
Code: Select all
This code loops through all of our resource files and extracts them one at a time using our function which we added earlier.Dim EmbeddedFilesList As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly()
For Each ResourceFile As String In EmbeddedFilesList.GetManifestResourceNames()
If Not ResourceFile.Contains(".resources") Then
ExtractResources(ResourceFile)
End If
Next
Now for the very important part that makes this whole thing work. Because this is an installer we obviously need to include our application and any files required. So locate your application folder (the application that you want to have installed) and add your Application.exe and any dlls, images, text files and anything else thats inside your application folder and add them ALL as resources into this project.
THIS IS IMPORTANT:
After you have added everything into resources you should see a new "Resources" folder in the solution explorer at the top-right of your screen like this:

You can see ive added my application and all the files that it needs as resources. Now once everything has been added you need to highlight/select ALL your resource files and take a look at the properties window directly below as seen in this image:

You need to change the "Build Action" propertie to "Embedded Resource" and then save your project.
Thats it your finished

I know it seems a bit basic just having 1 button but I did it this way so you can change/improve it to your own needs and requirements. You can add options to create shortcuts on the desktop and the start menu and even add status label or progress bar to show the installation progress and even add an uninstall feature.
I have added some of these features to the attached project file so you can get an idea of what you can do and just how easy it is ;).
Download: Happy coding cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Wow thanks a lot i always wanted to make a custom installer
Hi CodenStuff , thanks for this great tutorial
I want to ask if a user who downloaded my custom installer for my application , the user machine(computer) do not have .Net 2.0 above and how can they run the installer ?
I am looking for a way which the installer can launch without .Net and check if see the machine got .Net install to ensure my application can work .
And also ,
I really want to know how you did CNS that can embed dll usercontrols into another application forms . I want to learn that because i am building a very complex software and dun want all the forms and codes in one exe file .
Hope you can post a tutorial about that asap as you said above "Its Hard To coming up new things to do" why don't post this tutorial .
Thanks so much CodenStuff ~!

I want to ask if a user who downloaded my custom installer for my application , the user machine(computer) do not have .Net 2.0 above and how can they run the installer ?
I am looking for a way which the installer can launch without .Net and check if see the machine got .Net install to ensure my application can work .
And also ,
I really want to know how you did CNS that can embed dll usercontrols into another application forms . I want to learn that because i am building a very complex software and dun want all the forms and codes in one exe file .
Hope you can post a tutorial about that asap as you said above "Its Hard To coming up new things to do" why don't post this tutorial .
Thanks so much CodenStuff ~!

Hi Codenstuff
Nice one, just did the tutorial and i worked a treat cooll;
Quality
Chris
Nice one, just did the tutorial and i worked a treat cooll;
Quality
Chris
Hello,
Thanks for the comments
. I guess if you would have to include a link the .net redistributable with your installer just incase a user doesnt have it installed: http://www.microsoft.com/downloads/deta ... laylang=en most users will probably have it installed already anyway at some level.
I will post a tutorial on how to use add-ins when I have it all figured out and working properly cooll;
Thanks for the comments

I will post a tutorial on how to use add-ins when I have it all figured out and working properly cooll;
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
Hello,
I made an update to my original source-code which adds Repair and Uninstall buttons to it. The buttons only show if the application has already been installed just like a normal installer.
Download: I will post a tutorial later on how I did it cooll;
I made an update to my original source-code which adds Repair and Uninstall buttons to it. The buttons only show if the application has already been installed just like a normal installer.
Download: I will post a tutorial later on how I did it cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
this is cool. how can we add a Progress Bar that show the progress?
brill, gonna need this for my project, when i finish ima upload onto this site to give back all this help you've given me
That's a great tutorial.
I opted to create my own installer a while ago and I have something like the above however I have not yet found out how to properly fully install programs. The code I have done and the code provided do not add the program to the 'installed programs' list where you can add/remove/repair them. I'm guessing I'll have to find out how to edit the registry again which I am hoping I don't have to do. Do you know any methods of doing this code 'n' stuff.
I appreciate any such help.
I opted to create my own installer a while ago and I have something like the above however I have not yet found out how to properly fully install programs. The code I have done and the code provided do not add the program to the 'installed programs' list where you can add/remove/repair them. I'm guessing I'll have to find out how to edit the registry again which I am hoping I don't have to do. Do you know any methods of doing this code 'n' stuff.
I appreciate any such help.
Copyright Information
Copyright © Codenstuff.com 2020 - 2023