Creating a real Setup
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.
3 posts
Page 1 of 1
Hello,
Today i´m going to teach you how to make a real setup.
In this tutorial i´m not going to explain how to make the gui but i´m going to explain the code.
This is also my entry for the Global Offensive competition by RunarM
Screenshots of the final result:
Welcome page:
![Image]()
Select a Path page:
![Image]()
Installing page:
![Image]()
Finished Page:
![Image]()
The first step is creating the GUI you want for your installer. If you want to use my gui, download the project files.
The next step is the code:
First add the following reference: Windows Script Host Object Model (COM)
Next add the following codes:
Imports:
Then replace
For the GUI and other things download the project files:
Today i´m going to teach you how to make a real setup.
In this tutorial i´m not going to explain how to make the gui but i´m going to explain the code.
This is also my entry for the Global Offensive competition by RunarM
Screenshots of the final result:
Welcome page:

Select a Path page:

Installing page:

Finished Page:

The first step is creating the GUI you want for your installer. If you want to use my gui, download the project files.
The next step is the code:
First add the following reference: Windows Script Host Object Model (COM)
Next add the following codes:
Imports:
Code: Select all
Things that we need in the other part of the code:Imports System
Imports System.Net
Code: Select all
The next code is for creating a shortcut:WithEvents CopyClient As New WebClient
Dim Path As String
Dim Source As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\Sample\"
Dim P As Integer = 1
Dim X As Integer = 0
Dim C As Boolean = False
Dim Files As New ListView
Code: Select all
In the form closing event add this code:Dim IWshRuntimeLib As New IWshRuntimeLibrary.IWshShell_Class
Private Function CreateShortCut(ByVal shortcutName As String, ByVal creationDir As String, ByVal targetFullpath As String, ByVal workingDir As String, ByVal iconFile As String, ByVal iconNumber As Integer) As Boolean
Try
If Not IO.Directory.Exists(creationDir) Then
Dim retVal As DialogResult = MsgBox(creationDir & " does not exist. Do you wish to create it?", MsgBoxStyle.Question Or MsgBoxStyle.YesNo)
If retVal = DialogResult.Yes Then
IO.Directory.CreateDirectory(creationDir)
Else
Return False
End If
End If
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType(IWshRuntimeLib.CreateShortcut(creationDir & "\" & shortcutName & ".lnk"), IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = targetFullpath
shortCut.WindowStyle = 1
shortCut.Description = shortcutName
shortCut.WorkingDirectory = workingDir
shortCut.IconLocation = iconFile & ", " & iconNumber
shortCut.Save()
Return True
Catch ex As System.Exception
Return False
End Try
End Function
Code: Select all
The code for the Form_Load:If C = True Then
If MsgBox("Are you sure you want to cancel the installation", 36, "Cancel Installation") = MsgBoxResult.Yes Then
C = False
End If
End If
e.Cancel = C
Code: Select all
For the "Browse" button in your form add this code:page_Welcome.Visible = True
page_Welcome.Location = New Point(0, 0)
page_Welcome.Size = New Size(602, 383)
For Each file In My.Computer.FileSystem.GetFiles(Source)
Files.Items.Add(file)
Next
Code: Select all
The following codes are for the CopyClient, just copy and past it into the code: Dim f As New FolderBrowserDialog
With f
.Description = "Choose Path"
If .ShowDialog = Windows.Forms.DialogResult.OK Then
TextBox1.Text = .SelectedPath
End If
End With
Code: Select all
Next go to My Project -> Application and click on "View Windows Settings" Private Sub CopyClient_DownloadFileCompleted(ByVal sender As Object, ByVal e As System.ComponentModel.AsyncCompletedEventArgs) Handles CopyClient.DownloadFileCompleted
X += 1
If X > Files.Items.Count - 1 Then
page_Finished.Visible = True
page_Finished.Location = New Point(0, 0)
page_Finished.Size = New Size(602, 383)
P = 4
Button9.Text = "Finish"
Button9.Enabled = True
Button8.Visible = False
CreateShortCut("Program", My.Computer.FileSystem.SpecialDirectories.Desktop, Path & "\Program.exe", Path, Path & "\World-icon.ico", 0)
Else
CopyClient.DownloadFileAsync(New Uri(Files.Items.Item(X).Text), Path & "\" & Dir(Files.Items.Item(X).Text))
End If
End Sub
Private Sub CopyClient_DownloadProgressChanged(ByVal sender As Object, ByVal e As System.Net.DownloadProgressChangedEventArgs) Handles CopyClient.DownloadProgressChanged
ProgressBar1.Maximum = e.TotalBytesToReceive
ProgressBar1.Value = e.BytesReceived
End Sub
Then replace
Code: Select all
with level="asInvoker"
Code: Select all
The last thing is to create folder with the program name on your desktop with the bin/debug files in it and an Icon with .ico extension.level="requireAdministrator"
For the GUI and other things download the project files:
You do not have the required permissions to view the files attached to this post.
well its seems a nice project 
but seems it doesn't make the sample folder in program files
or even copy the files.
any idea?

but seems it doesn't make the sample folder in program files
or even copy the files.
any idea?
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
3 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023