Computing.Net > Forums > Programming > batch file parameters question

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

batch file parameters question

Reply to Message Icon

Name: qiqigre
Date: April 17, 2007 at 14:12:14 Pacific
OS: Windows 2000 server
CPU/Ram: 2G
Product: Dell
Comment:

Hi,
I am new to batch files. I recently read a batch file.
...
IF NOT EXIST %1 (CALL :CMDLine %1)
IF NOT EXIST %2 (CALL :CMDLine %2)
IF NOT EXIST %2\logs\%3 (CALL :CMDLine %3)
IF NOT EXIST %4 (CALL :CMDLine %4)
...
Parameters 1, 2, 3, 4 are paths and names of some applications.
The batch file was set up to run once every week automatically. I don't underestand how this file can find those parameters? Should I set up something so that the file know where those paraemters are?

Also, what does :CMDLINE mean?

Thanks!

qiqi



Sponsored Link
Ads by Google

Response Number 1
Name: IVO
Date: April 18, 2007 at 00:52:54 Pacific
Reply:

The %1, %2 and so on parameters are "external variables" to be coded on the batch's command tail, i.e. if the script is named MyBatch it would be launched as

MyBatch Param1 Param2 Param3 Param4

where ParamN as you posted are file/folder names.

:CDMLINE is a "label" for an internal subroutine to be called with the expressed tail parameter, i.e. if Param1 is C:\Test\MyFile (on the batch's command tail), then at run time

Call :CMDLINE %1

becomes

Call :CMDLINE C:\Test\MyFile

How this parameter is processed inside the routine and the difference between internal and external subroutine is far beyond thi short note.

Walking through the batch you'll find a label :CMDLINE at thr beginning of a line: that is the entry point of the internal subroutine that must end with GoTo :EOF.

This is a NT batch script mor powerfull than a native DOS one for Win 9X/ME; you have a long way to walk in front of you.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: batch file parameters question

Batch File www.computing.net/answers/programming/batch-file/14461.html

FTP batch file www.computing.net/answers/programming/ftp-batch-file/9027.html

batch file website login question www.computing.net/answers/programming/batch-file-website-login-question/7907.html