Results 1 to 7 of 7

Thread: Adding to TargetPath of a Shortcut

Threaded View

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2007
    Posts
    15

    Adding to TargetPath of a Shortcut

    Ok, after searching for hours in these forums for the answer to my question, I decided to sign up and ask it myself. I have been trying to figure how to search for an exe file on the computer, create a shortcut of it, and add some command line parameters to the targetpath. After searching I have found this code:

    Code:
    Option Explicit
    Private Sub Command1_Click()
     'This will Create a ShortCut of Notepad in our desktop, its name is "Notepad", minimize windows when run, use the 2nd icon as the Shortcut icon.
     Create_ShortCut "C:\WINDOWS\NOTEPAD.EXE", "Desktop", "Notepad", , 7, 1
     End Sub
    Sub Create_ShortCut(ByVal TargetPath As String, ByVal ShortCutPath As String, ByVal ShortCutname As String, Optional ByVal WorkPath As String, Optional ByVal Window_Style As Integer, Optional ByVal IconNum As Integer)
    Dim VbsObj As Object
    Set VbsObj = CreateObject("WScript.Shell")
    Dim MyShortcut As Object
    ShortCutPath = VbsObj.SpecialFolders(ShortCutPath)
    Set MyShortcut = VbsObj.CreateShortcut(ShortCutPath & "\" & ShortCutname & ".lnk")
    MyShortcut.TargetPath = TargetPath
    MyShortcut.WorkingDirectory = WorkPath
    MyShortcut.WindowStyle = Window_Style
    MyShortcut.IconLocation = TargetPath & "," & IconNum
    MyShortcut.Save
    End Sub
    I am using that to create my shortcut. So I have that part done. However when I try adding a string to the end of it, it puts the string in the quotes of the target path. I want it on the outside.

    Now I have a basic knowledge of VB and have taken a high school course in it, but if your going to post a really complicated code, could you please explain it to me? That's why I had to create a thread, because the other threads are too confusing to understand. Thanks for your help. I look forward to your reply.


    Also, how are you suppose to copy and paste the code in the code tags? It copies he numbers along with it.
    Last edited by gamerkd17; Apr 8th, 2007 at 03:50 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width