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,