Visual Basic 2010 Express: Determine USB Drive letter or find out from which drive the program is launched from.

Here2Help
Here2Help used Ask the Experts™
on
Hey.

I'm creating an application in Visual Basic 2010 Express. The app will launch other portable apps from a USB pen drive. The problem is I need to identify what the USB drive letter will be so I can get the correct path to the program file I want to launch. What variable can I use?

Or maybe there's another way to do this?

Cheers.

Example code (where E: should be a variable for the USB drive letter):


Shell ("E:\Programdir\Prog.exe")

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
High School Computer Science, Computer Applications, Digital Design, and Mathematics Teacher
Top Expert 2009
Commented:
You could do something like:
Dim Drive As String = System.IO.Path.GetPathRoot(Application.StartupPath)
        Dim App As String = System.IO.Path.Combine(Drive, "Programdir\Prog.exe")
        Process.Start(App)

Open in new window

Author

Commented:
Hey.

Just what I was looking for!

Thanks.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial