How do I make any executable dos code auto-detect a path?

December 25, 2011 at 10:45:50
Specs: Windows 7
I am writing a code to copy a few files for backup which is sort of everyday work for which I use CD using DOS to set the directory.

How do I create a DOS command line to auto detect the path were I have placed it (the location of code) rather than it automatically getting set to C:\Users\ME.

Sort of like:

CD C:\Users\ME\Ryan\Folder1
COPY *.txt C:\Users\ME\Ryan
CD C:\Users\ME\Ryan\Folder2
COPY *.xls C:\Users\ME\Ryan
{Code placed in C:\Users\ME\Ryan}

CD C:\Users\ME\Ethan\Folder1
COPY *.txt C:\Users\ME\Ethan
COPY *.xls C:\Users\ME\Ethan
{Code placed in C:\Users\ME\Ethan}

So Folder1 & Folder2 remains the same always.
So how can I make dos auto-update the path in the code (C:\Users\ME\Ryan, C:\Users\ME\Ethan) by checking where it exists.

Please help any clues would be appreciable. Thanks!!

See More: How do I make any executable dos code auto-detect a path?

Report •

December 26, 2011 at 07:52:12
Stated there is no DOS under Windows 7 since it is a NT kernel system, according to what you posted to auto set the folder holding your script code e.g.

copy *.xls "%~dp0"

Report •
Related Solutions

Ask Question