473,505 Members | 14,658 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Placing a .lnk file on the desktop

I am using the following code to locate the desktop folder. After doing
this, I would like to place a shortcut on the desktop that opens a specific
folder. How do I create the .lnk file for a folder called "C:\Temp"? Help
of any type would be appreciated.

Dim regPath As RegistryKey =
Registry.CurrentUser.OpenSubKey("Software\Microsof t\Windows\CurrentVersion\Explorer\Shell Folders")

If Not regPath Is Nothing Then
sPath = (regPath.GetValue("Desktop")).ToString
End If

What next?
Jul 31 '06 #1
3 1788
Hi,

I've done this before... but don't have the code in front of me.
Create a shortcut the normal way. Then in command prompt, navigate to
the folder where the shortcut exists. Use MORE or something similar to
show the contents of the .lnk file. You will see the text that
constructs the link. Then, on your desktop, create a text file
something.txt and enter the same data as your link. Then, all you need
to do is rename the .txt as a .lnk and it becomes a shortcut.

So everything I just said to do manually, you can have your application
do as well. I deployed my shortcuts as .dat files and then later
renamed them as .lnk files AFTER copying them to the user's desktop.

Naturally you can use .NET to programatically create the text that goes
into your text file, thus allowing you to create a dynamic shortcut on
the fly.

Sorry for not having code present.

SN

Jul 31 '06 #2
"genojoe" <ge*****@discussions.microsoft.comschrieb:
>I am using the following code to locate the desktop folder. After doing
this, I would like to place a shortcut on the desktop that opens a
specific
folder. How do I create the .lnk file for a folder called "C:\Temp"?
Help
of any type would be appreciated.

Dim regPath As RegistryKey =
Registry.CurrentUser.OpenSubKey("Software\Microsof t\Windows\CurrentVersion\Explorer\Shell
Folders")
You may want to use 'Environment.GetFolderPath' instead.
If Not regPath Is Nothing Then
sPath = (regPath.GetValue("Desktop")).ToString
End If

What next?
<URL:http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp>
<URL:http://vbaccelerator.com/article.asp?id=4301>

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

Jul 31 '06 #3
Hello genojoe,

Based on http://msdn2.microsoft.com/en-us/library/fywyxt64.aspx please
find the solution below:

Dim Shell As Object, Link As Object
Dim DesktopPath As String

Shell = CreateObject("WScript.Shell")

DesktopPath = Shell.SpecialFolders("Desktop")

Link = Shell.CreateShortcut(DesktopPath & "\MyTestLink.lnk")

Link.Arguments = "C:\WINDOWS\regopt.log"

link.Description = "test shortcut"

link.HotKey = "CTRL+ALT+SHIFT+X"

Link.IconLocation = "C:\Windows\system32\SHELL32.dll,1"

Link.TargetPath = "c:\windows\notepad.exe"

link.WindowStyle = 3

Link.WorkingDirectory = "c:\Windows"

link.Save()
Best Regards,

HKSHK
genojoe wrote:
I am using the following code to locate the desktop folder. After doing
this, I would like to place a shortcut on the desktop that opens a specific
folder. How do I create the .lnk file for a folder called "C:\Temp"? Help
of any type would be appreciated.

Dim regPath As RegistryKey =
Registry.CurrentUser.OpenSubKey("Software\Microsof t\Windows\CurrentVersion\Explorer\Shell Folders")

If Not regPath Is Nothing Then
sPath = (regPath.GetValue("Desktop")).ToString
End If

What next?
Jul 31 '06 #4

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

Similar topics

1
7738
by: bmgz | last post by:
I am have made a simple script that moves all desktop clutter (ie files that are not *.lnk) to a specified folder eg. c:\myhome\mydocs\desktopdebris\2003-12-16 ...
11
6592
by: Abhishek | last post by:
I have a problem transfering files using sockets from pocket pc(.net compact c#) to desktop(not using .net just mfc and sockets 2 API). The socket communication is not a issue and I am able to...
2
2807
by: Dickyb | last post by:
Extracting an Icon and Placing It On The Desktop (C# Language) I constructed a suite of programs in C++ several years ago that handle my financial portfolio, and now I have converted them to...
4
4494
by: sunilj20 | last post by:
Hello, I have a requirement wherein, a user clicks on a file name in an ASP.NET web application, and the file should automatically be downloaded (Without showing the "Open", "Save As") in the...
4
2092
by: Ray Stevens | last post by:
Is it possible to place a company icon (logo) in the browser address field so that if a user copies it as a shortcut to his desktop the icon will be there. For example, like this:...
3
1923
by: Lasse Eskildsen | last post by:
Hi, I have a form, and I would like it to act a bit like the taskbar, so that the icons in the desktop, won't hide under it, but instead move away from under the form. Is this possible with...
4
1153
by: vvenk | last post by:
Hello: I have an ASP application that takes a file and parses it. I have a fileUpload control on my ASP page. Here's the code that gets file details: Dim srFile As StreamReader Try srFile...
1
5601
by: pbrown | last post by:
Hi, I'm using VB.net 2003, and I have a problem. I need a way of saving a file directly to the desktop, without hardcoding the direct path to the desktop into the program. For example, I'm trying...
4
1651
by: mikkoO8 | last post by:
hi. im actually making a desktop cleaner that can move the files and icons to a folder inside the listview box. i can make the listview box filled with files contains at the desktop and i can make...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
7018
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
7471
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...
1
5028
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...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.