Modify *.lnk File?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Duchtel

    Modify *.lnk File?

    Hello -

    I'm trying to put together a little VB .NET (1.1 in VS 2003)
    application that lets me substitute the path in the Target: and Start
    in: fields of *.lnk files. Is there any way to do that?

    I saw examples of VBScripts using WSH but I would like to do it in
    VB .NET. Is support for *.lnk built into .NET?

    Thanks,
    Joe
  • kimiraikkonen

    #2
    Re: Modify *.lnk File?

    On Jun 6, 2:35 pm, Joe Duchtel <duch...@gmail. comwrote:
    Hello -
    >
    I'm trying to put together a little VB .NET (1.1 in VS 2003)
    application that lets me substitute the path in the Target: and Start
    in: fields of *.lnk files. Is there any way to do that?
    >
    I saw examples of VBScripts using WSH but I would like to do it in
    VB .NET. Is support for *.lnk built into .NET?
    >
    Thanks,
    Joe
    Hi Joe,
    I couldn't find a native way for modifying shortcuts, but you can do
    by referencing "Windows script host object model" from COM tab.

    And a sample code for you:
    Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
    Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
    ' Set path of shorcut (.lnk) file
    shortCut = CType((New
    IWshRuntimeLibr ary.WshShell).C reateShortcut(" shortcut.lnk"), _
    IWshRuntimeLibr ary.IWshShortcu t)
    shortCut.Target Path = "target_path_he re"
    shortCut.Descri ption = "description_he re"
    ' Save
    shortCut.Save()

    ..and hoping that is useful for who are looking for similar help :)

    Thanks,

    Onur Güzel

    Comment

    • Joe Duchtel

      #3
      Re: Modify *.lnk File?

      Hello -

      Perfect ... works like a charm! The only question I have is whether
      it is really necessary to set the Copy Local to True for the
      Interop.IWshRun timeLibrary.dll . It does not seem to find this *.dll
      if I set the Copy Local to False. I just don't like having to
      distribute extra files with an *.exe.

      Thanks a lot!
      Joe



      On Jun 6, 2:38 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
      On Jun 6, 2:35 pm, Joe Duchtel <duch...@gmail. comwrote:
      >
      Hello -
      >
      I'm trying to put together a little VB .NET (1.1 in VS 2003)
      application that lets me substitute the path in the Target: and Start
      in: fields of *.lnk files.  Is there any way to do that?
      >
      I saw examples of VBScripts using WSH but I would like to do it in
      VB .NET.  Is support for *.lnk built into .NET?
      >
      Thanks,
      Joe
      >
      Hi Joe,
      I couldn't find a native way for modifying shortcuts, but you can do
      by referencing "Windows script host object model" from COM tab.
      >
      And a sample code for you:
      Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
      Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
      ' Set path of shorcut (.lnk) file
      shortCut = CType((New
      IWshRuntimeLibr ary.WshShell).C reateShortcut(" shortcut.lnk"), _
      IWshRuntimeLibr ary.IWshShortcu t)
      shortCut.Target Path = "target_path_he re"
      shortCut.Descri ption = "description_he re"
      ' Save
      shortCut.Save()
      >
      ..and hoping that is useful for who are looking for similar help :)
      >
      Thanks,
      >
      Onur Güzel

      Comment

      • kimiraikkonen

        #4
        Re: Modify *.lnk File?

        On Jun 7, 6:32 am, Joe Duchtel <duch...@gmail. comwrote:
        Hello -
        >
        Perfect ... works like a charm! The only question I have is whether
        it is really necessary to set the Copy Local to True for the
        Interop.IWshRun timeLibrary.dll . It does not seem to find this *.dll
        if I set the Copy Local to False. I just don't like having to
        distribute extra files with an *.exe.
        >
        Thanks a lot!
        Joe
        >
        On Jun 6, 2:38 pm, kimiraikkonen <kimiraikkone.. .@gmail.comwrot e:
        >
        On Jun 6, 2:35 pm, Joe Duchtel <duch...@gmail. comwrote:
        >
        Hello -
        >
        I'm trying to put together a little VB .NET (1.1 in VS 2003)
        application that lets me substitute the path in the Target: and Start
        in: fields of *.lnk files. Is there any way to do that?
        >
        I saw examples of VBScripts using WSH but I would like to do it in
        VB .NET. Is support for *.lnk built into .NET?
        >
        Thanks,
        Joe
        >
        Hi Joe,
        I couldn't find a native way for modifying shortcuts, but you can do
        by referencing "Windows script host object model" from COM tab.
        >
        And a sample code for you:
        Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
        Dim shortCut As IWshRuntimeLibr ary.IWshShortcu t
        ' Set path of shorcut (.lnk) file
        shortCut = CType((New
        IWshRuntimeLibr ary.WshShell).C reateShortcut(" shortcut.lnk"), _
        IWshRuntimeLibr ary.IWshShortcu t)
        shortCut.Target Path = "target_path_he re"
        shortCut.Descri ption = "description_he re"
        ' Save
        shortCut.Save()
        >
        ..and hoping that is useful for who are looking for similar help :)
        >
        Thanks,
        >
        Onur Güzel
        Glad it worked! I recommend you to also have this library in your
        application folder, think that, what if the library is not present on
        target machine? However, after you build your project the library is
        copied to your application's bin\debug folder anyway, then you're
        ready to deploy your application.

        Thanks,

        Onur Güzel

        Comment

        • Kevin S Gallagher

          #5
          Re: Modify *.lnk File?

          Why not treat it as an INI file since it's plain text instead of using
          classes like WshShell

          "Joe Duchtel" <duchtel@gmail. comwrote in message
          news:23a36a89-8b8e-4a2e-9e82-ace16b680441@k3 7g2000hsf.googl egroups.com...
          Hello -
          >
          I'm trying to put together a little VB .NET (1.1 in VS 2003)
          application that lets me substitute the path in the Target: and Start
          in: fields of *.lnk files. Is there any way to do that?
          >
          I saw examples of VBScripts using WSH but I would like to do it in
          VB .NET. Is support for *.lnk built into .NET?
          >
          Thanks,
          Joe

          Comment

          • Herfried K. Wagner [MVP]

            #6
            Re: Modify *.lnk File?

            "Kevin S Gallagher" <kevin.s.gallag her@state.or.us schrieb:
            Why not treat it as an INI file since it's plain text instead of using
            classes like WshShell
            I think you are referring to URL files.

            The shell link format is a "binary" format.

            --
            M S Herfried K. Wagner
            M V P <URL:http://dotnet.mvps.org/>
            V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

            Comment

            • =?Utf-8?B?QnJpYW5odWI=?=

              #7
              Re: Modify *.lnk File?

              I am using this technique to modify an existing shortcut too. It seems to be
              working well except for some inconsistencies in how the tooltip is displayed.
              We wanted to tool tip to up as two lines like the Internet Explorer shortcut
              with the Name of the shortcut in the first line and the description in the
              second line. The IE shortcut only has the description in the comment field.
              When I create our shortcut this way it only shows the description as a single
              line tooltip. However, every once in a while it will display correctly as a
              two line tooltip. If I modify the comment field to display the name and a new
              line character and the description it displays correctly most of the time.
              However, in this case sometimes it displays a three line tooltip with the
              name displayed twice.

              There must be a way to reliably display the tooltip correctly because to IE
              shortcut always seems to work. Does anyone know of a way to fix this?

              --
              Brian


              "Herfried K. Wagner [MVP]" wrote:
              "Kevin S Gallagher" <kevin.s.gallag her@state.or.us schrieb:
              Why not treat it as an INI file since it's plain text instead of using
              classes like WshShell
              >
              I think you are referring to URL files.
              >
              The shell link format is a "binary" format.
              >
              --
              M S Herfried K. Wagner
              M V P <URL:http://dotnet.mvps.org/>
              V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
              >

              Comment

              Working...