Messages - TheFormatter [ switch to compact view ]

Pages: [1]

In regards to handling the command line arguments from the "regular" environment as opposed to the 4DOS environment, you can get the whole command line with this:

ECHO Command Line:  %0 %*

And the parameter list with this:

ECHO Command Line Parameters:  %*


Batches? We don't need no stinkin' batches!


Sorry, I'm a little late getting into this thread, but there is some help I can provide:

As for the question

How do I represent the current directory of the batch file I am using along with the files to be copied?

the lightly documented %CD% variable that has been in the cmd environment for the last few revs will do what you need.

If you start the batch or cmd file in the directory f:\data, then %CD% will equal f:\data, so instead of looking like this

copy f:\data\data.exe c:\windows\system32\data
copy f:\data\pic.jpg C:\Documents and Settings\Administrator\Desktop

your copy lines would look something like this:

copy %CD%\data.exe c:\windows\system32\data
copy %CD%\pic.jpg C:\Documents and Settings\Administrator\Desktop

So it won't matter what drive or directory the batch file is executed from.  Please keep in mind that the %CD% represents the current command line directory - you can call the batch/cmd file from anywhere using the full path to it, but %CD% will contain the current drive and directory.

The above phrase hurts my eyes, so an example might be more in order.

CopyMyFiles.cmd is stored in C:\Scripts
At the command prompt, you change directories to F:\Data
From there you type in the command
The %CD% variable will contain the value F:\Data.

I hope that hasn't muddied the waters.


If you think the problem is bad now, wait until I solve it!

Pages: [1]
Go to full version