|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Placing a .lnk file on the desktopI 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\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") If Not regPath Is Nothing Then sPath = (regPath.GetValue("Desktop")).ToString End If What next? 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 "genojoe" <geno***@discussions.microsoft.com> schrieb: You may want to use 'Environment.GetFolderPath' instead.>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\Microsoft\Windows\CurrentVersion\Explorer\Shell > Folders") > If Not regPath Is Nothing Then <URL:http://www.msjogren.net/dotnet/eng/samples/dotnet_shelllink.asp>> sPath = (regPath.GetValue("Desktop")).ToString > End If > > What next? <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/> 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: Show quoteHide quote > 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\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders") > > If Not regPath Is Nothing Then > sPath = (regPath.GetValue("Desktop")).ToString > End If > > What next?
How to change printer's physical print margins thru VB coding?
2 pieces of the same code doing different things Custom Attributes, Shared methods, Derived classes and reflection allowing just numeric value in my textbox *** HELP *** Problems Accessing Simple VB.NET Access Database Cross-thread operation not valid How to validate Date entries. Wanted: Simple VB.NET "WEB" Application with an Access Database String translation Saving an image from the browser |
|||||||||||||||||||||||