I just gave an example in another thread, here's a copy.
If you're in a batch file, you use parameters. For instance, if you wanted to run DIR and save the directory specification in an environment variable...
<contents of test.bat>
dir %1
set PARAMETER=%1
To invoke the batch job, an example is:
TEST C:\TEMP
When it runs, PARAMETER in the environment will contain C:\TEMP