473,748 Members | 5,230 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select Shortcut path in VB.NET

115 New Member
i'm using VB.NET 2003 application program.

by using OpenFileDialog, we can select the file name or file path.
Expand|Select|Wrap|Line Numbers
  1.         OpenFileDialog1.ShowDialog()
  2.         pgmPath.Text = OpenFileDialog1.FileName
  3.  
by using FolderBrowserDi alog, we can select the folder name or folder path.
Expand|Select|Wrap|Line Numbers
  1.          FolderBrowserDialog1.ShowDialog()
  2.         folderPath.Text = FolderBrowserDialog1.SelectedPath
  3.  
is there a way i can select shortcut. i just want to select shortcut for a folder. but when i used FolderBrowserDi alog, it show only the folder list. its not showing the shortcut i have.

for example: in desktop i have 4 folders, 1 EXE shortcut and 1 folder shortcut. but when i open FolderBrowserDi alog it shows only 4 folders, not showing the 2 shortcuts.
a way i can show files that end with ".lnk" and select that shortcut. is there a way i can select shortcut's...

and by using this shell command i tried to open the EXE's.
Expand|Select|Wrap|Line Numbers
  1. ProgramPath = "C:\Programs\Application1.exe"
  2.  
  3. Shell(Chr(34) & ProgramPath & Chr(34), AppWinStyle.NormalFocus)
  4.  
and it works fine with all the EXE to get opened.

but when i tried to open a shortcut using the same shell comment
Expand|Select|Wrap|Line Numbers
  1. ProgramPath = "C:\Programs\App.lnk"
  2.  
  3. Shell(Chr(34) & ProgramPath & Chr(34), AppWinStyle.NormalFocus)
  4.  
error occurs... "File Not Found"

is there a way i can open the shortcut.

if anyone have any idea how to select shortcut (files that end with ".lnk") and a way i can open the shortcut, please help me. if you can provide any help, then that will be great help for me...

Thanks in advance.
Dec 8 '08 #1
5 6520
Plater
7,872 Recognized Expert Expert
For the first part:
Use the OpenFileDialog and set the filter to *.lnk maybe?
That should show folders and files that end in .lnk (shortcuts?)

To address the second part:
You should not be using old VB commands in a net project (if you can avoid it). And in this case you can. The Process/ProcessStartInf o classes are the ones you should be usings.
Dec 8 '08 #2
remya1000
115 New Member
Thanks for your reply and help.

as you said i tried OpenFileDialog. its showing the Shortcut file. but when i select any shortcut file, it's going inside the shortcut folder. not able to select the shortcut file.

for example: if you have shortcut file called "Shortcut of App". so if you select that, its showing the App folder and we need to select anything inside that. but not able to select the App.lnk.

if i have "shortcut to App" in DeskTop or anywhere else and if i need to select that, how come i do that.

if you have any idea how to do this, please help me and if you can provide an example, then that will be great help for me.

Thanks in Advance
Dec 8 '08 #3
anijos
52 New Member
Try this

if (OpenFileDialog .FileName.ToLow er().EndsWith(" .lnk"))
{
ShellShortcut shortcut = new ShellShortcut(O penFileDialog.F ileName);
String FileName = shortcut.Path;
String Arguments= shortcut.Argume nts;
String WorkingDirector y = shortcut.Workin gDirectory;
}

AniJos
Dec 9 '08 #4
Plater
7,872 Recognized Expert Expert
You need to se the DereferenceLink s property of your OpenFileDialog to the correct value I think
Dec 9 '08 #5
remya1000
115 New Member
Thank for you help anijos and Plater.

As you said i tried this code...
Expand|Select|Wrap|Line Numbers
  1.         OpenFileDialog1.Filter = "(*.LNK;*.EXE)|*.lnk;*.exe"
  2.         OpenFileDialog1.DereferenceLinks = False
  3.         OpenFileDialog1.ShowDialog()
  4.  
so now it allow to select .exe or .lnk files. now i'm able to select .lnk files...

That worked... Once again thanks a lots for your help...
Dec 9 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

27
2876
by: aa | last post by:
Thought this question might be out of this NG's scope, there are always knowledgable people who might hava an answer. A hyperlink to a shortcut to a file returnes an empty screen, and the source code behind this empty screen is <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML><HEAD> <META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD> <BODY></BODY></HTML> Is this supposed to be like this? ...
2
2526
by: Benjamin | last post by:
I have a very strange problem. I have developed a .NET solution. To set up user clients I have also included a "Deployment Project" in the solution: Using "File System Editor | User's Program Menu" configuration a "Shortcut" is created and pointing to the client EXE-file. The created msi-file, NETProgram.msi, works perfectly on the clients. A Start Menu shortcut is correctly created in "C:\Documents and Settings\All
0
2043
by: Pete | last post by:
If using the FileOpenSave common dialog box (ahtCommonFileOpenSave) the text string it extracts is the full path of the file which is great. The problem is if a .url or .lnk (internet shortcut or regular shortcut) file is selected then the path is not extracted. Does anyone know a work around for this. What I would like to do is prompt the user for a file and if it is a shortcut store the actual shortcut file (filename.lnk). If anyone...
7
1165
by: Paul Mars | last post by:
How can I make a shortcut to the exe in bin. I want this shortcut in root application dir. However, it can not use the entire path. It needs to just look from root down two levels to bin, not starting at drive letter. How can I do this?? Thanks, paul
6
3443
by: =?Utf-8?B?UmljaA==?= | last post by:
Greetings, I am deploying vb2005 apps using Click Once deployment. This works fine. The problem is that the user needs to be able to launch a 2nd app from the 1st app, but the application startup paths are different for each user. However, the shortcuts for these apps are created in the same Start directory for each user. Is it possible to launch app2 from app1 by calling the shortcut of app2 (or vice versa)? How to do this? Or, how...
6
9608
by: Eric | last post by:
I am using remote desktop to access our Access database. I created a shortcut to the Access file on my desktop, but when i double click it, nothing happens. Even when I try to double click the actual file I still cant open it. The only way I can open it is to open Access File-->Open. Can someone please tell me why the shortcut wont work? Thanks.
2
2777
by: Jorgen Bodde | last post by:
Hi all, This is slightly OT but it drives me nuts. Whenever I create a shortcut in the start menu (in Windows) of a python script, it will only execute it when the path where the script resides in contains no spaces. For example; d:\src\app\app.py If I drag that to the Start Menu it can be executed fine.
10
3549
by: Matthew Wells | last post by:
I'm trying to make a shortcut that will open an mdb in the same folder as the shortcut - regardless of where the file/shortcut may be. In other words, I want to be able to copy and paste the two files anywhere and have the shortcut always open the mdb that was copied with it without having to change the shortcut properties. If I only use the mdb name without any path, the shortcut tries to look in the folder where msaccess.exe is. I've...
4
1655
by: Coolfusion | last post by:
Hi there, I want the programe to search for the shortcut exe file on the desktop and display the file path of the file. To obtain the file path manually, right-click the shortcut exe file and go to properties and the path is under the row called Target. Currently the code i wrote cannot display the path. Can you tell me wat is the problem. I m currently using vb.net 2003. Thanks in advance Private Sub cmdGet_Path_Click(ByVal sender...
0
8991
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8830
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9372
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8243
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4606
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2215
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.