If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Rate Thread | Display Modes |
#1
|
|||
|
|||
I need help writing a position independent CMD script
I need help writing a position independent CMD script.
I'm helping a friend write a CMD script that is called by another script in windows 7. It does a lot of stuff, but the issue is encapsulated by the following... Directory structure is D:\ program root directory dir1 somefiles dir2 copyscript.bat The copyscript.bat is one line xcopy dir1\*.* dir2 The script works fine when executed from program root directory. But it's called from a script on another partition. Xcopy can't find dir1 or dir2. It's looking in system32. The current workaround is to add the following D: cd pathto program root directory That fixes the problem, but it's position dependent. How do we modify the script so that it runs no matter where program root directory is? How can the script determine it's location? In the current context, it's executed from task scheduler. Task scheduler allows inputting the working directory. That's not the question. Ditto for calling the script thru a shortcut. I want to learn the path syntax for writing a self-contained position-independent CMD script that uses relative addressing in the version of CMD interpreter that's in win7. Explanations and links are fine, but the ideal answer would also edit the above one-line script to make it position independent. The devil is in the details. I've already googled my ass off. I'm lost in escape sequences and parentheses and pre-defined system variables and the fact that CMD lines may parse differently if they're in a script. Using a different scripting language won't help. I'd have to learn it and teach it and become "customer support" forever. That's way beyond what I'm willing to do. |
Thread Tools | |
Display Modes | Rate This Thread |
|
|