Message 1 of 4
iLogic save to lnk (Shortcut)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello.
Does anyone know how to save a to an lnk Shortcut in iLogic?
I try everything but without success, see code variants I have tried.
This seems to be a thing:
Imports IWshRuntimeLibrary
'Sub CreateShortCut(ByVal TargetName As String, ByVal ShortCutPath As String, ByVal ShortCutName As String)
''Dim Shell As New WshShell.
''Dim Shortcut As WshShortcut
'Dim Shell As IWshRuntimeLibrary.WshShell
'Dim Shortcut As IWshRuntimeLibrary.WshShortcut
' 'initialize the object WshShell
' Shell = New WshShell
' 'initialize the object WshShortcut
' 'the complete name of the .lnk file, include full path plus the .LNK file extension
' objShortcut = objShell.CreateShortcut (txtLnkName.Text)
' 'the file to be called by the .lnk file, ej. "c:\windows\calc.exe"
' Shortcut.TargetPath = TargetName
' '(optional) := any command line supported by the file indicated in txtTarget.Text
' 'objShortcut.Arguments = xxxx
' '(optional) : = a valid icon file : = To use the same icon of the target file, do not use the next line.
' 'objShortcut.IconLocation = xxxx
' 'Save the .lnk
' Shortcut.Save
'End Sub
'Private Sub CreateShortCut(ByVal FileName As String, ByVal Title As String)
' Try
' Dim WshShell As New WshShell
' ' short cut files have a .lnk extension
' Dim Shortcut As IWshRuntimeLibrary.IWshShortcut = DirectCast(WshShell.CreateShortcut(FileName, IWshRuntimeLibrary.IWshShortcut)
' ' set the shortcut properties
' With Shortcut
' .TargetPath = Application.ExecutablePath
' .WindowStyle = 1I
' .Description = Title
' .WorkingDirectory = Application.StartupPath
' ' the next line gets the first Icon from the executing program
' .IconLocation = Application.ExecutablePath & ", 0"
' .Arguments = String.Empty
' .Save() ' save the shortcut file
' End With
' Catch ex As System.Exception
' MessageBox.Show("Could not create the shortcut" & Environment.NewLine & ex.Message, g_strAppTitleVersion, MessageBoxButtons.OK, MessageBoxIcon.Error)
' End Try
'End Sub
'Private Function CreateShortCut(ByVal TargetName As String, ByVal ShortCutPath As String, ByVal ShortCutName As String) As Boolean
' Dim oShell As Object
' Dim oLink As Object
' ' You don’t need to import anything in the project reference to create the Shell Object
' Try
' oShell = CreateObject("WScript.Shell")
' oLink = oShell.CreateShortcut(ShortCutPath & "\" & ShortCutName & ".lnk")
' oLink.TargetPath = TargetName
' oLink.WindowStyle = 1
' oLink.Save()
' Catch ex As Exception
' End Try
'End Function
'Private Sub CreateShortCut(TargetPath As String, WorkingDirectory As String)
' Dim wsh As WshShellClass = New WshShellClass()
' Dim Shortcut As IWshRuntimeLibrary.IWshShortcut = TryCast(wsh.CreateShortcut(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\shorcut.lnk"), IWshRuntimeLibrary.IWshShortcut)
' Shortcut.Arguments = ""
' Shortcut.TargetPath = TargetPath '"c:\app\myftp.exe"
' Shortcut.WindowStyle = 1
' Shortcut.Description = "my shortcut description"
' Shortcut.WorkingDirectory = WorkingDirectory '"c:\app"
' Shortcut.IconLocation = "specify icon location"
' Shortcut.Save()
'End Sub