我们需要对参数进行硬编码,以便用户只需要运行bat文件来升级许可证(We need to hardcode arguments so all the user need to do is just needs to run the bat file to upgrade the license)
我们将更新的许可证存储在'style.mfx'文件中。 我们希望发送给用户并让它以该名称静默替换旧文件。 文件将始终位于c:。 我试过这个演示没有运气。 我想在批处理文件中硬编码targetName和replacementFile。
@echo off set targetName=%~NX1 set replacementFile=%~F2 call :processFolder goto :EOF :processFolder rem For each folder in this level for /D %%a in (*) do ( rem Enter into it, process it and go back to original cd %%a if exist "%targetName%" ( copy "%replacementFile%" "%targetName%" /Y ) call :processFolder cd .. ) exit /Bcmd线甚至没有工作! 但我想要批处理文件中的参数......
app teststyle.mfx c:\teststyle.mfx c:\Users\Joseph\Desktop>replace.bat teststyle.mfx c:\teststyle.mfx c:\Users\Joseph\Desktop>任何帮助,将不胜感激。
We have an updated license stored in the file 'style.mfx'. We want to send to user and have it silently replace the old file by that name. The File will always be in c:. I've tried this demo with no luck. I want to hard code targetName and replacementFile in the batch file.
@echo off set targetName=%~NX1 set replacementFile=%~F2 call :processFolder goto :EOF :processFolder rem For each folder in this level for /D %%a in (*) do ( rem Enter into it, process it and go back to original cd %%a if exist "%targetName%" ( copy "%replacementFile%" "%targetName%" /Y ) call :processFolder cd .. ) exit /Bcmd line isn't even working! but I want the arguments in the batch file...
app teststyle.mfx c:\teststyle.mfx c:\Users\Joseph\Desktop>replace.bat teststyle.mfx c:\teststyle.mfx c:\Users\Joseph\Desktop>Any help would be appreciated.
最满意答案
:processFolder rem For each folder in this level for /D %%a in (*) do ( rem Enter into it, process it and go back to original pushd "%%a" if exist "%targetName%" ( copy "%replacementFile%" "%targetName%" /Y popd ) goto :eofpushd/popd可用于保存和返回。
到达文件结尾将从call ed例程返回。
:processFolder rem For each folder in this level for /D %%a in (*) do ( rem Enter into it, process it and go back to original pushd "%%a" if exist "%targetName%" ( copy "%replacementFile%" "%targetName%" /Y popd ) goto :eofpushd/popd can be used to save-and-return.
reaching end-of-file will return from a called routine.
更多推荐
发布评论