none
How to Create ShortCut For a Folder in vb.net

    Question

  • Hello Every One

                 I use vb.net 2005 . I need to create a short cut for a folder. For example

    I need create shortcut for “C:\SourceFolder “in “D:\ DistenFolder” and also find

    How many Shortcuts are present in this folder?

    Regards,
    Navaratan

    Thursday, June 04, 2009 10:51 AM

Answers

  • Hello Mr.A.m.a.L
          Thank's for replay

                   currenty i use this code .
    first :- Add Reference "Windows Scripting Host Object Model " on COM tab.

    Imports IWshRuntimeLibrary

    Public Class FolderHandling

        Private WshShell As WshShellClass

        ''' <summary>

        ''' Code for create short cut for a file AND ALSO FOLDER .

        ''' </summary>

        ''' <param name="sender"></param>

        ''' <param name="e"></param>

        ''' <remarks>Navaratan Sharma 4-6-2009</remarks>

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

            Try

                WshShell = New WshShellClass()

                Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut

                MyShortcut = DirectCast(WshShell.CreateShortcut("C:\NAVARATAN Short cut.lnk"), IWshRuntimeLibrary.IWshShortcut)

             MyShortcut.TargetPath = "C:\NewCRMDocuments\CRMFolderSpace"                           MyShortcut.Description = "ToolTip On SHORT CUT"

                MyShortcut.IconLocation = "C:\Program Files\Microsoft Office\OFFICE11\REFBAR.ICO"  MyShortcut.Save()

            Catch ex As Exception

                MessageBox.Show(ex.Message.ToLower)

            End Try

        End Sub


    '''

     

    <summary>
    ''' This Code For Short cut is Present On Path.

     

    ''' </summary>

     

    ''' <returns></returns>

     

    ''' <remarks>Navaratan 4-6-2009</remarks>

     

    Public Function IsShortcutPresent() As Boolean

     

        If IO.File.Exists("C:\NAVARATAN Short cut.lnk") Then

     

              Return True

     

        Else

     

             Return False

     

        End If

     

    End Function

     

     

     

     

     

     


    End class


    • Marked as answer by Navaratan Friday, June 05, 2009 6:39 AM
    Thursday, June 04, 2009 12:10 PM

All replies

  • Check this link

    http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp


    Thanks,
    A.m.a.L
    .Net Goodies
    Remember to click "mark as answered" when you get a correct reply to your question
    Thursday, June 04, 2009 11:00 AM
  • Hello Mr.A.m.a.L
          Thank's for replay

                   currenty i use this code .
    first :- Add Reference "Windows Scripting Host Object Model " on COM tab.

    Imports IWshRuntimeLibrary

    Public Class FolderHandling

        Private WshShell As WshShellClass

        ''' <summary>

        ''' Code for create short cut for a file AND ALSO FOLDER .

        ''' </summary>

        ''' <param name="sender"></param>

        ''' <param name="e"></param>

        ''' <remarks>Navaratan Sharma 4-6-2009</remarks>

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

            Try

                WshShell = New WshShellClass()

                Dim MyShortcut As IWshRuntimeLibrary.IWshShortcut

                MyShortcut = DirectCast(WshShell.CreateShortcut("C:\NAVARATAN Short cut.lnk"), IWshRuntimeLibrary.IWshShortcut)

             MyShortcut.TargetPath = "C:\NewCRMDocuments\CRMFolderSpace"                           MyShortcut.Description = "ToolTip On SHORT CUT"

                MyShortcut.IconLocation = "C:\Program Files\Microsoft Office\OFFICE11\REFBAR.ICO"  MyShortcut.Save()

            Catch ex As Exception

                MessageBox.Show(ex.Message.ToLower)

            End Try

        End Sub


    '''

     

    <summary>
    ''' This Code For Short cut is Present On Path.

     

    ''' </summary>

     

    ''' <returns></returns>

     

    ''' <remarks>Navaratan 4-6-2009</remarks>

     

    Public Function IsShortcutPresent() As Boolean

     

        If IO.File.Exists("C:\NAVARATAN Short cut.lnk") Then

     

              Return True

     

        Else

     

             Return False

     

        End If

     

    End Function

     

     

     

     

     

     


    End class


    • Marked as answer by Navaratan Friday, June 05, 2009 6:39 AM
    Thursday, June 04, 2009 12:10 PM