Feedback

VB - Make Shortcut

Veröffentlicht von am 9/5/2010
(1 Bewertungen)
With this function you can create a shortcut where ever you want. For example on the Desktop or in Startup folder.

Example:
MakeShortcut("C:\Windows\notepad.exe", "C:\Users\Marvin\Desktop", "Notepad", "C:\Windows")
    Private Function MakeShortcut(ByVal File As String, ByVal ShortcutFolder As String, ByVal Name As String, ByVal WorkDirectory As String)
        Dim WshShell As Object = CreateObject("WScript.Shell")
        Dim NewShortcut As Object = WshShell.CreateShortcut(ShortcutFolder & "\" & Name & ".lnk")

        NewShortcut.TargetPath = File
        NewShortcut.WindowStyle = 1
        NewShortcut.IconLocation = File & ",0"
        NewShortcut.WorkingDirectory = WorkDirectory
        NewShortcut.Save()
    End Function

Kommentare zum Snippet

 

Logge dich ein, um hier zu kommentieren!