CodeWarrior
Addict
- Joined
- Feb 16, 2014
- Posts
- 23
- Reaction
- 16
- Points
- 78
- Age
- 39
Good day this simple tutorial demonstrate how to create a shortcut link to your application.
this is a basic tutorial but even the pro programmer use this code for there application.
Lets start:
Now open your vb.net language any version and create new project. Name your project
On toolbox drag and drop or double click the Button icon. You must need two button for
our tutorial sample Button1.Text = "Add Shortcut" and the Button2.Text = "Remove Shortcut"
Above the Public Class Form1 you need to Import some of our References "IWshRuntimeLibrary"
Double Click your form and press ctrl+a and delete everything then copy ang paste this code
Now Press F5 to start debugging, Click Add Shortcut Button to create and shortcut link
Click Remover Shortcut Button to remove all shorcut link of your project..
Happy Happy Coding...
Credited to ME
this is a basic tutorial but even the pro programmer use this code for there application.
Lets start:
Now open your vb.net language any version and create new project. Name your project
On toolbox drag and drop or double click the Button icon. You must need two button for
our tutorial sample Button1.Text = "Add Shortcut" and the Button2.Text = "Remove Shortcut"
Above the Public Class Form1 you need to Import some of our References "IWshRuntimeLibrary"
Double Click your form and press ctrl+a and delete everything then copy ang paste this code
Code:
Imports IWshRuntimeLibrary
Public Class Form1
' This dimension is for Startup folder at All Program Menu
Dim StartupDir1 As String = Environment.GetFolderPath(Environment.SpecialFolder.Startup)
' This dimension is for Desktop
Dim StartupDir2 As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim shortcutFilePath1 As String = StartupDir1 & "\AutoAddStartUpFolder.lnk"
Dim shortcutFilePath2 As String = StartupDir2 & "\AutoAddStartUpFolder.lnk"
' Create Shortcut
Private Sub CreatShortcut()
Dim WShell As WshShellClass = New WshShellClass
Dim MyShortcut1 As IWshRuntimeLibrary.IWshShortcut
Dim MyShortcut2 As IWshRuntimeLibrary.IWshShortcut
MyShortcut1 = CType(WShell.CreateShortcut(shortcutFilePath1), _
IWshRuntimeLibrary.IWshShortcut)
MyShortcut2 = CType(WShell.CreateShortcut(shortcutFilePath2), _
IWshRuntimeLibrary.IWshShortcut)
MyShortcut1.TargetPath = Application.StartupPath & "\AutoAddStartUpFolder.exe"
MyShortcut2.TargetPath = Application.StartupPath & "\AutoAddStartUpFolder.exe"
MyShortcut1.Save() : MyShortcut2.Save()
End Sub
' Remove Shortcut
Private Sub RemoveShortcut()
If IO.File.Exists(shortcutFilePath1) OrElse IO.File.Exists(shortcutFilePath2) Then
IO.File.Delete(shortcutFilePath1) : IO.File.Delete(shortcutFilePath2)
End If
End Sub
' Button1 is for creating a shortcut
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
CreatShortcut()
End Sub
' Button2 is for removing the shortcut
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
RemoveShortcut()
End Sub
End Class
Now Press F5 to start debugging, Click Add Shortcut Button to create and shortcut link
Click Remover Shortcut Button to remove all shorcut link of your project..
Happy Happy Coding...
Credited to ME