I'm trying to get my VB.Net program to create one shortcut on the
desktop not during install but while running. I found this code at site:
http://www.tek-tips.com/faqs.cfm?fid=6127
I also added a reference to a com named:
''Windows Script Host Object Model''.
My problem is that the 'wShell' shown in red in the code above is
underlined as an error and says:
'Name wShell is not declared'.
How do I declare it?
desktop not during install but while running. I found this code at site:
http://www.tek-tips.com/faqs.cfm?fid=6127
VB.NET:
[SIZE=2][COLOR=#0000ff]Imports[/COLOR][/SIZE][SIZE=2] IWshRuntimeLibrary
[/SIZE]
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
IO.Directory.CreateDirectory(creationDir)
Else
Return False
End If
End If
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
shortCut = CType([COLOR=red]wShell[/COLOR].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
I also added a reference to a com named:
''Windows Script Host Object Model''.
My problem is that the 'wShell' shown in red in the code above is
underlined as an error and says:
'Name wShell is not declared'.
How do I declare it?