简体   繁体   English

调用其他批处理文件后,批处理分解

[英]Batch break up after call other batch file

i have the problem, that my batch process breaking up each time after call a other batch file. 我的问题是,每次调用另一个批处理文件后,我的批处理过程都会中断。 The batch files are used to run a make process out from IBM Rhapsody. 批处理文件用于从IBM Rhapsody中运行制作过程。 There convert the call from Rhapsody to the Visual Studio tools. 在那里将调用从Rhapsody转换为Visual Studio工具。 So nmake will be called from the batch after make different settings. 因此,在进行不同的设置后,将从批处理中调用nmake。

The scripts aren't written completely from me, I only adapt theme to run under both windows architecture versions, x86 and x64. 这些脚本不是完全由我编写的,我只修改了主题使其可以在x86和x64两种Windows体系结构版本下运行。 The first script (vs2005_make.bat) will be called from Rhapsody and run to the “call” statement. Rhapsody将调用第一个脚本(vs2005_make.bat),并运行到“ call”语句。 The second script (Vcvars_VisualStudio2005.bat) runs to the end. 第二个脚本(Vcvars_VisualStudio2005.bat)运行到最后。 But the first script isn't resume working, at this point the process break up without a error message. 但是第一个脚本无法恢复工作,这时该过程中断了,没有错误消息。

I'm not very familiar with batch files, this is the first time I make more than simple console commands in a batch file. 我对批处理文件不是很熟悉,这是我第一次在批处理文件中进行比简单的控制台命令更多的操作。 So I hope I have given all information's which needed, otherwise ask me. 所以我希望我已经提供了所有需要的信息,否则请问我。

Here the start script (vs2005_make.bat): 下面是启动脚本(vs2005_make.bat):

:: parameter 1 - Makefile which should be used
:: parameter 2 - The make target mark

@echo off

IF "%2"==""        set target=all
IF "%2"=="all"     set target=all
IF "%2"=="build"   set target=all
IF "%2"=="rebuild" set target=clean all
IF "%2"=="clean"   set target=clean

set RegQry="HKLM\Hardware\Description\System\CentralProcessor\0"
REG.exe Query %RegQry% > checkOS.txt 
Find /i "x86" < CheckOS.txt > StringCheck.txt

IF %ERRORLEVEL%==0 (
  set arch=x86
) ELSE (
  set arch=x64
)

call "%ProgramFiles%\IBM\Rhapsody752\Share\etc\Vcvars_VisualStudio2005.bat" %arch%

IF %ERRORLEVEL%==0 (
  set makeflags=
  nmake /nologo /S /F %1 %target%
) 

del checkOS.txt
del StringCheck.txt

exit

and here the called script (Vcvars_VisualStudio2005.bat): 这里是调用脚本(Vcvars_VisualStudio2005.bat):

:: param 1 - Processor architecture

@echo off

ECHO param 1 = %1

IF %1==x86 (
    SET ProgrammPath=%ProgramFiles%
) ELSE IF %1==x64 (
    SET ProgrammPath=%ProgramFiles(x86)%
) ELSE (
    ECHO Unknowen architectur
    EXIT /B 1
)

SET VSINSTALLDIR="%ProgrammPath%\Microsoft Visual Studio 8\Common7\IDE"
SET VCINSTALLDIR="%ProgrammPath%\Microsoft Visual Studio 8"
SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
SET FrameworkVersion=v2.0.50727
SET FrameworkSDKDir="%ProgrammPath%\Microsoft Visual Studio 8\SDK\v2.0"
rem Root of Visual Studio common files.

IF %VSINSTALLDIR%=="" GOTO Usage
IF %VCINSTALLDIR%=="" SET VCINSTALLDIR=%VSINSTALLDIR%

rem
rem Root of Visual Studio ide installed files.
rem
SET DevEnvDir=%VSINSTALLDIR%

rem
rem Root of Visual C++ installed files.
rem
SET MSVCDir=%VCINSTALLDIR%\VC

SET PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%Common7  \Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%;
SET INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\PlatformSDK\include\gl;%MSVCDir%\PlatformSDK\include;%FrameworkSDKDir%\include;%INCLUDE%
SET LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib;%FrameworkSDKDir%\lib;%LIB%

GOTO end

:Usage

ECHO. VSINSTALLDIR variable is not set. 
ECHO.
ECHO SYNTAX: %0

GOTO end

:end

Here the console output, what I not understand here and find very suspicious is that after the “IF %ERRORLEVEL%” Statement in the first script all will be put out regardless the echo is set to off… 在此控制台输出中,我在这里不了解并发现非常可疑的是,无论回显设置为off,在第一个脚本中的“ IF%ERRORLEVEL%”语句之后,所有内容都将被放出…

Executing: "C:\Programme\IBM\Rhapsody752\Share\etc\vs2005_make.bat" Simulation.mak build

IF %ERRORLEVEL%==0 (
Mehr?   set arch=x86
Mehr? ) ELSE (
Mehr?   set arch=x64
Mehr? )

call "%ProgramFiles%\IBM\Rhapsody752\Share\etc\Vcvars_VisualStudio2005.bat" %arch%
:: param 1 - Processor architecture

@echo off

ECHO param 1 = %1
param 1 = x86

IF %1==x86 (
Mehr?   SET ProgrammPath=%ProgramFiles%
Mehr? ) ELSE IF %1==x64 (
Mehr?   SET ProgrammPath=%ProgramFiles(x86)%
Mehr? ) ELSE (
Mehr?   ECHO Unknowen architectur
Mehr?   EXIT /B 1
Mehr? )

SET VSINSTALLDIR="%ProgrammPath%\Microsoft Visual Studio 8\Common7\IDE"
SET VCINSTALLDIR="%ProgrammPath%\Microsoft Visual Studio 8"
SET FrameworkDir=C:\WINDOWS\Microsoft.NET\Framework
SET FrameworkVersion=v2.0.50727
SET FrameworkSDKDir="%ProgrammPath%\Microsoft Visual Studio 8\SDK\v2.0"
rem Root of Visual Studio common files.

IF %VSINSTALLDIR%=="" GOTO Usage
IF %VCINSTALLDIR%=="" SET VCINSTALLDIR=%VSINSTALLDIR%

rem
rem Root of Visual Studio ide installed files.
rem
SET DevEnvDir=%VSINSTALLDIR%

rem
rem Root of Visual C++ installed files.
rem
SET MSVCDir=%VCINSTALLDIR%\VC

SET PATH=%DevEnvDir%;%MSVCDir%\BIN;%VCINSTALLDIR%\Common7\Tools;%VCINSTALLDIR%\Common7\Tools\bin\prerelease;%VCINSTALLDIR%\Common7\Tools\bin;%FrameworkSDKDir%\bin;%FrameworkDir%\%FrameworkVersion%;%PATH%;
SET INCLUDE=%MSVCDir%\ATLMFC\INCLUDE;%MSVCDir%\INCLUDE;%MSVCDir%\PlatformSDK\include\gl;%MSVCDir%\PlatformSDK\include;%FrameworkSDKDir%\include;%INCLUDE%
SET LIB=%MSVCDir%\ATLMFC\LIB;%MSVCDir%\LIB;%MSVCDir%\PlatformSDK\lib;%FrameworkSDKDir%\lib;%LIB%

GOTO end

Build Done    

I hope someone have an idea, i work now since two days and don't find the error... thanking you in anticipation. 我希望有人有一个主意,我从两天开始工作,没有发现错误...感谢您的期待。

Note: The word “Mehr?” in the text output is german and means “more”. 注意:文本输出中的“ Mehr?”一词是德语,表示“更多”。 I don't know were it comes from and it is possible that it is a bad translation from the English output to german. 我不知道它是从哪里来的,而且很可能是从英语输出到德语的错误翻译。

The word 'mehr'/'more' is from the cmd.exe, as it leave the batch context. 单词“ mehr” /“ more”来自cmd.exe,因为它离开了批处理上下文。
The question is, why it can do this? 问题是,为什么它可以做到这一点?
Normally this happens in a loop starting another batch without CALL. 通常,这种情况发生在循环中,开始了另一个没有CALL的批处理。

So my best guess is, that you have a FIND.BAT file in one of the path directories. 所以我最好的猜测是,您在路径目录之一中有一个FIND.BAT文件。 You could try to remark the FIND command in your batch. 您可以尝试在批处理中标记FIND命令。

You could also test echo ### %undefined% . 您还可以测试echo ### %undefined%
If it's still in batch context you only see the hashes, else it echos ### %undefined% . 如果它仍处于批处理环境中,则只能看到哈希值,否则会回显### %undefined%

Then you could move the line to find the causing command. 然后,您可以移动该行以找到引起问题的命令。

such constructions doesn't work because of a parsing error with parentheses in variables, avoid it: 此类构造由于变量中带有括号的解析错误而无法使用,请避免使用:

IF %1==x86 (
     SET ProgrammPath=%ProgramFiles%
) ELSE IF %1==x64 (
     SET ProgrammPath=%ProgramFiles(x86)%
) ELSE (
     ECHO Unknowen architectur
     EXIT /B 1
)

use always variables in double quotes, eg.: 始终在双引号中使用变量,例如:

IF "%~1"=="x86" (
     SET "ProgrammPath=%ProgramFiles%"
) ELSE IF "%~1"=="x64" (
     SET "ProgrammPath=%ProgramFiles(x86)%"
) ELSE (
     ECHO Unknown architecture
     EXIT /B 1
)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM