How can I pass arguments to a batch file?

后端 未结 18 2154
陌清茗
陌清茗 2020-11-22 02:53

I need to pass an ID and a password to a batch file at the time of running rather than hardcoding them into the file.

Here\'s what the command line looks like:

18条回答
  •  长发绾君心
    2020-11-22 03:30

    There is no need to complicate it. It is simply command %1 %2 parameters, for example,

    @echo off
    
    xcopy %1 %2 /D /E /C /Q /H /R /K /Y /Z
    
    echo copied %1 to %2
    
    pause
    

    The "pause" displays what the batch file has done and waits for you to hit the ANY key. Save that as xx.bat in the Windows folder.

    To use it, type, for example:

    xx c:\f\30\*.* f:\sites\30
    

    This batch file takes care of all the necessary parameters, like copying only files, that are newer, etc. I have used it since before Windows. If you like seeing the names of the files, as they are being copied, leave out the Q parameter.

提交回复
热议问题