我想从另一个批处理创建一个批处理文件。那么我如何在新蝙蝠中编写代码,而不在原始蝙蝠中执行呢?到目前为止,我的代码是:
SET var1=%~dp0
SET var2
for %%a in ("%cd%") do set var2=%%~na
echo bla %var1% bla >> build%var2%.bat
应该有多行代码,而不是“bla”。我该如何存档?
编辑:
现在我的代码如下所示:
SET var1=%~dp0
SET var2
for %%a in ("%cd%") do set var2=%%~na
SET string = (
echo SET mdbname=%var2%
echo SET OfficeDIR=%%ProgramFiles(x86)%%\Microsoft Office\Office14
echo SET WorkDIR=%var1%
echo md build
echo copy %%mdbname%%.mdb build\%%mdbname%%.mda /Y
echo "%%officedir%%\msaccess.exe" /compact "%%WorkDir%%\build\%%mdbname%%.mda"
echo "D:****.exe" "%%WorkDir%%\build\%%mdbname%%.mda" "D:\****** Key - Nicht weitergeben" "%%officedir%%"
echo copy "%%WorkDir%%\build\%%mdbname%%.mda" "%%ProgramFiles(x86)%%\*******" /Y
)
echo %string% >> built%var2%.bat
但在新创建的批次中,只写了:“ECHO ist eingeschaltet (ON)”。/ "ECHO 已激活 (ON)。"
编辑2:
现在看起来像这样,什么也没有发生,甚至没有创建文件
SET var1=%~dp0
SET var2
for %%a in ("%cd%") do set var2=%%~na
(echo SET mdbname=%var2%
echo SET OfficeDIR=%%ProgramFiles(x86)%%\Microsoft Office\Office14
echo SET WorkDIR=%var1%
echo md build
echo copy %%mdbname%%.mdb build\%%mdbname%%.mda /Y
echo "%%officedir%%\msaccess.exe" /compact "%%WorkDir%%\build\%%mdbname%%.mda"
echo "D:\TFS\RepV\RepV 6.1\ITPBuildTool61.exe" "%%WorkDir%%\build\%%mdbname%%.mda" "D:\TFS\RepV\RepV 6.1\ITPEAK.OLKey Private Key - Nicht weitergeben" "%%officedir%%"
echo copy "%%WorkDir%%\build\%%mdbname%%.mda" "%%ProgramFiles(x86)%%\Sage\Office Line\6.1\Addin\Work" /Y) > built%var2%.bat