473,386 Members | 1,710 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,386 software developers and data experts.

Select Shortcut path in VB.NET

115 100+
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 FolderBrowserDialog, 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 FolderBrowserDialog, 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 FolderBrowserDialog 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 6466
Plater
7,872 Expert 4TB
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/ProcessStartInfo classes are the ones you should be usings.
Dec 8 '08 #2
remya1000
115 100+
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
Try this

if (OpenFileDialog.FileName.ToLower().EndsWith(".lnk" ))
{
ShellShortcut shortcut = new ShellShortcut(OpenFileDialog.FileName);
String FileName = shortcut.Path;
String Arguments= shortcut.Arguments;
String WorkingDirectory = shortcut.WorkingDirectory;
}

AniJos
Dec 9 '08 #4
Plater
7,872 Expert 4TB
You need to se the DereferenceLinks property of your OpenFileDialog to the correct value I think
Dec 9 '08 #5
remya1000
115 100+
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
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...
2
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...
0
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...
7
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...
6
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...
6
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...
2
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...
10
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...
4
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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,...
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...

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.