Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows 我们需要硬编码参数,所以用户只需运行bat文件即可升级许可证_Windows_Batch File_Hardcode - Fatal编程技术网

Windows 我们需要硬编码参数,所以用户只需运行bat文件即可升级许可证

Windows 我们需要硬编码参数,所以用户只需运行bat文件即可升级许可证,windows,batch-file,hardcode,Windows,Batch File,Hardcode,我们已将更新的许可证存储在文件“style.mfx”中。我们希望发送给用户,并让它以该名称静默地替换旧文件。该文件将始终使用c:。 我试过这个演示,但运气不好。我想在批处理文件中硬编码targetName和replacementFile @echo off set targetName=%~NX1 set replacementFile=%~F2 call :processFolder goto :EOF :processFolder rem For each folder in this l

我们已将更新的许可证存储在文件“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
命令行甚至不工作!但是我想要批处理文件中的参数

app teststyle.mfx c:\teststyle.mfx

c:\Users\Joseph\Desktop>replace.bat teststyle.mfx c:\teststyle.mfx

c:\Users\Joseph\Desktop>
任何帮助都将不胜感激

: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
可用于保存和返回


到达文件末尾时,将从调用程序返回。ed例程。

是否确实要以静默方式更改用户计算机上的许可证文件?是。''''。在开发批处理文件时,尤其是使用棘手的bug时,请删除
@echo off
,然后您可以看到它运行每一行代码,并在缓冲区中滚动查看出错的线索。这是joseph的另一个话题