|
-
June 24th, 2008, 05:40 PM
#2
Re: opening files with changing file paths
If you and the school both use Windows XP (I don't know how to use batch on other versions of windows), I use batch scripting very frequently in my computer (i.e. a quick, easy to use compiler for my .cpp files), so that may be something to look into.
(a quick reference is to open up command prompt and type "help [command]" or "[command] /?" or "help" for a list of commands)
I know it has nothing really to do with C++, but it isn't a bad Windows XP solution.
example set:
prog.cpp
Code:
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
if (argc == 2) {
cout << "Highest drive found is: " << argv[1] << endl;
}
return 0;
}
(note: first find out what the highest probable drive letter is, like F:, which normally occurs when only 2 devices are connected (A, C, and D are floppy drive, HDD, CD drive)
NOTE: The below script is only useful if your data key is the latest device to be connected to windows and therefore receives the highest letter(closest to Z), as would be expected
script.bat (REM = remark, or comment line)
Code:
if exist G: goto g
REM goes to label 'g' if drive G: is found
if exist F: goto f
if exist E: goto e
:g
prog G:
REM launches prog.exe with G: as first argument, when prog.exe is in the same directory
exit /b
:f
prog F:
exit /b
:e
prog E:
exit /b
lastly, right-click a .bat file and click edit to change it. If you don't know how to make batch scripts, I can make one for you if you tell me:
- folders on the data key
- what you are doing with the files (reading, copying to main disk, etc.)
- a file or folder that is directly inside your data key (like WINDOWS is in C:\)
- all drive letters used on yours and the school's computer
Last edited by Bluefox815; June 24th, 2008 at 05:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|