473,408 Members | 2,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

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
Jun 27 '08 #1
6 5842
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 IWshRuntimeLibrary.IWshShortcut
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
' Set path of shorcut (.lnk) file
shortCut = CType((New
IWshRuntimeLibrary.WshShell).CreateShortcut("short cut.lnk"), _
IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = "target_path_here"
shortCut.Description = "description_here"
' Save
shortCut.Save()

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

Thanks,

Onur Güzel
Jun 27 '08 #2
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.IWshRuntimeLibrary.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.comwrote:
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 IWshRuntimeLibrary.IWshShortcut
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
' Set path of shorcut (.lnk) file
shortCut = CType((New
IWshRuntimeLibrary.WshShell).CreateShortcut("short cut.lnk"), _
IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = "target_path_here"
shortCut.Description = "description_here"
' Save
shortCut.Save()

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

Thanks,

Onur Güzel
Jun 27 '08 #3
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.IWshRuntimeLibrary.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.comwrote:
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 IWshRuntimeLibrary.IWshShortcut
Dim shortCut As IWshRuntimeLibrary.IWshShortcut
' Set path of shorcut (.lnk) file
shortCut = CType((New
IWshRuntimeLibrary.WshShell).CreateShortcut("short cut.lnk"), _
IWshRuntimeLibrary.IWshShortcut)
shortCut.TargetPath = "target_path_here"
shortCut.Description = "description_here"
' 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
Jun 27 '08 #4
Why not treat it as an INI file since it's plain text instead of using
classes like WshShell

"Joe Duchtel" <du*****@gmail.comwrote in message
news:23**********************************@k37g2000 hsf.googlegroups.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

Jun 27 '08 #5
"Kevin S Gallagher" <ke***************@state.or.usschrieb:
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/>
Jun 27 '08 #6
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" <ke***************@state.or.usschrieb:
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/>
Aug 21 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chris McKeever | last post by:
I am trying to modify the Mailman Python code to stop mapping MIME-types and use the extension of the attachment instead. I am pretty much clueless as to what I need to do here, but I think I have...
4
by: pmud | last post by:
Hi I have a website (ASP.NET project using C# ) which is already put up on the server. I need to make some modification to some web pages.So the project files were copied to the a different server...
12
by: Venkat | last post by:
Greetings to All, I have the following file and i need to modify it with the contents of an array File1.txt Name Location Points Grade Venkat,Newyork,100,A Jack,LA,12,C
3
by: Maileen | last post by:
Hi, I've asked yesterday if someone already modify data into XML file using VB.NET. In fact, my XML file is like that. .... <DB> <DB_Loc>
3
by: muttu2244 | last post by:
hi everybody am trying to modify a particular string from a csv file. for ex say i have compName, ipAddr, MacAddr, Os sdfsdf , 129.122.12.34 , dsfiasdf, wsfdjhs
4
by: muttu2244 | last post by:
Hi everybody Am trying to read a csv file "temp.csv", which has the below info, compName macAddr ipAddr opSys
1
by: LB | last post by:
Hi, I want to modify my file ".vbproj". I use XML dlls of Visual Studio and that causes to modify the format of the file .vbproj and that causes problems at the compile time on another servor....
1
by: TimEl | last post by:
Hi. Using Perl, I want to modify data in an XML file and print out the entire modified file, not just the elements I modify. In CPAN I have found that XPath allows me to pinpoint the elements...
6
by: Ramesh | last post by:
Hello, I am using the ofstream class to create a text file with keys and values like: Key1=Value10 Key2=Value15 Key3=Value20 In case I need to set a new value for Key2, say value50 - I am...
2
by: letobale1982 | last post by:
Hello I would like to get some ideas on how to modify a Combobox during runtime and save the changes so next time the form is ran changes are available. Here is the plan. A form displays a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.