05-18-2017 01:51 AM
Hello !
I am french and I develop a program on LabWindows/CVI 2013.
I have to launch a file (aaaa.exe) when my program start. But this file (aaaa.exe) is located in a USB Key. So I have to read the USB Ports to detect the key, and after, find if the file (aaaa.exe) exists in the key. If the file (aaaa.exe) exists, I launch it.
But I don't know which functions I can use to do this... ?
Thanks
Best regards
Solved! Go to Solution.
05-18-2017 08:46 AM - edited 05-18-2017 08:50 AM
If you are running on a Windows system, your computer should assign a drive letter to the USB key when it is inserted. So if you know what drive letter will be assigned, you can call FileExists to check for the file and LaunchExecutableEx to run it. Typically your hard drive is C and your CD/DVD drive is D, so your USB drive is likely to be E (possibly F or G if your computer has multiple CD/DVD drives or if another USB device was inserted first). So at most you should have to check a few drive letters.
If you're running on a Linux system, you need to call a system function to mount the USB drive before you can access it. This article describes how:
05-18-2017 09:01 AM
Thanks richferrara !
I've just find the solution !
In my case, I don't know the letter of my USB drive.
So I used the function "GetLogicalDriveStrings()" to catch all the Drive letter of my computer and after that I used "FileExists()" to detect my file !