Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / December 2004

Tip: Looking for answers? Try searching our database.

how to create a shortcut to a folder programmatically from VB.NET

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dev guy - 23 Nov 2004 06:01 GMT
hi

how to create a shortcut to a folder programmatically from VB.NET?

regards,
Sudhakar Sadasivuni[mvp] - 29 Nov 2004 12:33 GMT
Yes, via Windows Script Shell (WSH) api, you can create shortcuts to folders
prgramatically..

01. Add a reference to WSH Library (COM References Tab > Scripting Host
Object Model)

the following code creates a shortcut on desktop with various options given...

Public Function CreateShortCutOnDesktop(ByVal userID As String, _
     ByVal passWord As String) As Boolean
     Try
        Dim DesktopDir As String = _
           CType(WshShell.SpecialFolders.Item("Desktop"), String)
        Dim shortCut As IWshRuntimeLibrary.IWshShortcut

        ' short cut files have a .lnk extension
        shortCut = CType(WshShell.CreateShortcut(DesktopDir & _
          "\MyNewShortcut.lnk"), _
            IWshRuntimeLibrary.IWshShortcut)

        ' set the shortcut properties
        With shortCut
           .TargetPath = _
              System.Reflection.Assembly.GetExecutingAssembly.Location()
           .WindowStyle = 1
           .Description = "Run Typist Summary"
           .WorkingDirectory = DesktopDir
           ' the next line gets the first Icon from the executing program
           .IconLocation = _
             System.Reflection.Assembly.GetExecutingAssembly.Location() & _
             ", 0"
          ' the next line sets the userID and passWord into the shortcut
           ' as arguments
           ' which will be read from the command line.
           .Arguments = userID & ", " & passWord
           .Save() ' save the shortcut file
        End With
        Return True
     Catch ex As System.Exception
        ' add your error handling here, if any
        Return False
     End Try
  End Function

Sudhakar Sadasivuni
http://weblogs.asp.net/ssadasivuni
MyUG : http://www.mugh.net

> hi
>
> how to create a shortcut to a folder programmatically from VB.NET?
>
> regards,
dev guy - 09 Dec 2004 06:56 GMT
Hi

I did follw the instructions... though it works only for Files. And not
FOLDERs.

-- regards

> Yes, via Windows Script Shell (WSH) api, you can create shortcuts to folders
> prgramatically..
[quoted text clipped - 49 lines]
> >
> > regards,

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.