-
Path Problem
ok im trying to create a menu program that will launch as soon as my pen drive is connected...problem is...while writing my code i have no idea what the Drive letter for my pen drive is until i get to that pc...
Obviously i dont want to open Dev C++ just to change the code to match that pc.. so is there a way to make a path that kinda either searches all the drives for the Executable or somthing...?
Code:
int sel = getch();
if(sel == '1')
{
cls
system("..\\Linker\\Apps\\login2.exe"); //activates the .exe file for Login2
}
if(sel == '2')
{
cls
system("..\\Linker\\Apps\\Warrior.exe"); //activates the .exe file for Warrior
}
if(sel == '3')
{
cls
system("..\\Linker\\Apps\\PCLock.exe"); //activates the .exe file for PCLock
}
main();
that is a piece out of my code... i tried using ".." as the begining of the path but the complier didnt like that, anyhelp would be great
-
If you begin a path with a \ ("\\) it indicates the current drive. But that depends on where the program is called from not the programs location.
-
** Yep that works i just changed the path to "\\Linker\\Apps\\programname.exe" and it worked since both the main EXE and the ones its calling are both on the Pendrive it automaticly starts from that drive letter.. Thanks
-
I would say yes.
The only time it wouldn't work would be if the current drive were different for example if you were in a command prompt at the c:\windows prompt and you started the program on the pen drive by typing it into the command prompt the current drive would be C:.
-
yeah thats true, but the program is made to Autorun as soon as the pendrive is connected, or if you start it from within the folder in the pendrive
its basicly made so that i can pop my pen drive in and choose one of my most used programs to work with right there, i guess im just getting to lazy to click about 4 times lol!
-
alright well now im stuck on the autorunning from the pendrive....anyone got any ideas?
i already made the Autorun.inf file, but i dont know how to go aobut getting it to start as soon as the pen drive is plugged in....lol this is sooo off the subjest of c++ now lol
-
Do you have to enable play for USB devices? Maybe its not enabled by default like CD-ROM drives.