我们需要对参数进行硬编码,以便用户只需要运行bat文件来升级许可证(We need to hardcode arguments so all the user need to do is just n

编程入门 行业动态 更新时间:2024-10-25 16:22:21
我们需要对参数进行硬编码,以便用户只需要运行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 /B

cmd线甚至没有工作! 但我想要批处理文件中的参数......

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 /B

cmd 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 :eof

pushd/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 :eof

pushd/popd can be used to save-and-return.

reaching end-of-file will return from a called routine.

更多推荐

本文发布于:2023-08-03 18:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1396380.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:只需要   许可证   参数   文件   用户

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!