topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday March 28, 2024, 4:59 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - TheFormatter [ switch to compact view ]

Pages: [1]
1
wolf.b:

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:  %*

Jim

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

2
foolios

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
       C:\Scripts\CopyMyFiles.cmd
The %CD% variable will contain the value F:\Data.

I hope that hasn't muddied the waters.


Jim

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

Pages: [1]