window7打不开.bat文件,每次打开,闪一下就没有了

@echo off
REM Licensed to the Apache Software Foundation (ASF) under one
REM or more contributor license agreements. See the NOTICE file
REM distributed with this work for additional information
REM regarding copyright ownership. The ASF licenses this file
REM to you under the Apache License, Version 2.0 (the
REM "License"); you may not use this file except in compliance
REM with the License. You may obtain a copy of the License at
REM
REM http://www.apache.org/licenses/LICENSE-2.0
REM
REM Unless required by applicable law or agreed to in writing,
REM software distributed under the License is distributed on an
REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
REM KIND, either express or implied. See the License for the
REM specific language governing permissions and limitations
REM under the License.
rem ---------------------------------------------------------------------------
rem Axis2 Script
rem
rem Environment Variable Prequisites
rem
rem AXIS2_HOME Must point at your AXIS2 directory
rem
rem JAVA_HOME Must point at your Java Development Kit installation.
rem
rem JAVA_OPTS (Optional) Java runtime options
rem ---------------------------------------------------------------------------
set CURRENT_DIR=%cd%
rem Make sure prerequisite environment variables are set
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
goto end
:gotJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
goto okJavaHome
:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK/JRE
goto end
:okJavaHome
rem check the AXIS2_HOME environment variable
if not "%AXIS2_HOME%" == "" goto gotHome
set AXIS2_HOME=%CURRENT_DIR%
if exist "%AXIS2_HOME%\bin\java2wsdl.bat" goto okHome
rem guess the home. Jump one directory up to check if that is the home
cd ..
set AXIS2_HOME=%cd%
cd "%CURRENT_DIR%"
:gotHome
if EXIST "%AXIS2_HOME%\lib\axis2*.jar" goto okHome
echo The AXIS2_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome
rem set the classes
setlocal EnableDelayedExpansion
rem ----- Execute The Requested Command ---------------------------------------
echo Using AXIS2_HOME: %AXIS2_HOME%
echo Using JAVA_HOME: %JAVA_HOME%
set _RUNJAVA="%JAVA_HOME%\bin\java"
%_RUNJAVA% %JAVA_OPTS% -Djava.ext.dirs="%AXIS2_HOME%\lib\" -Daxis2.repo="%AXIS2_HOME%\repository" -Daxis2.xml="%AXIS2_HOME%\conf\axis2.xml" %*
endlocal
:end

按这代码编的,不闪退才怪!估计你 :end 后面丢了几句回显代码吧!
至少end后面也是如下的代码才对!
==============================
:end
echo 显示所检测的问题,然后提示退出.....
pause>nul
exit
===============================
.....

在end代码不修改的情况下,每段后面pause都没用就直接goto end,保准一闪就没!
如下加入了pause,至少不会闪退了,至于功能上,我没修改代码,删除了冗余的REM注释,稍加中文注释,凑合看吧~
这代码大意是检测java的环境变量配置,估计需要放到安装目录下运行。。。。
============================================
@echo off
set CURRENT_DIR=%cd%
rem 检测环境变量是否设置,若设置继续往下,否则退出...
if not "%JAVA_HOME%" == "" goto gotJavaHome
echo The JAVA_HOME environment variable is not defined
echo This environment variable is needed to run this program
echo 提醒:环境变量未设置,任意键退出脚本....
pause>nul
goto end

:gotJavaHome
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
goto okJavaHome

:noJavaHome
echo The JAVA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo NB: JAVA_HOME should point to a JDK/JRE
echo 未检测到JDK/JRE,任意键退出...
pause>nul
goto end

:okJavaHome
rem 检查 AXIS2_HOME 环境变量...
if not "%AXIS2_HOME%" == "" goto gotHome
set AXIS2_HOME=%CURRENT_DIR%
if exist "%AXIS2_HOME%\bin\java2wsdl.bat" goto okHome
rem guess the home. Jump one directory up to check if that is the home
cd ..
set AXIS2_HOME=%cd%
cd "%CURRENT_DIR%"

:gotHome
if EXIST "%AXIS2_HOME%\lib\axis2*.jar" goto okHome
echo The AXIS2_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
echo 任意键退出....
pause>nul
goto end

:okHome
rem set the classes
setlocal EnableDelayedExpansion

rem ----- Execute The Requested Command ---------------------------------------
echo Using AXIS2_HOME: %AXIS2_HOME%
echo Using JAVA_HOME: %JAVA_HOME%
set _RUNJAVA="%JAVA_HOME%\bin\java"
%_RUNJAVA% %JAVA_OPTS% -Djava.ext.dirs="%AXIS2_HOME%\lib\" -Daxis2.repo="%AXIS2_HOME%\repository" -Daxis2.xml="%AXIS2_HOME%\conf\axis2.xml" %*
endlocal

:end
exit
温馨提示:内容为网友见解,仅供参考
第1个回答  2013-01-04
你先选开始 运行 cmd
用cd 进入该bat所在的目录
直接输入该bat的名字运行。看这时候显示什么。
你直接点击运行时因为运行结束后窗口自动退出了,你没办法看到运行结果的现实。
看这个bat脚本应该是运行AXIS2
你在运行该脚本前需要配置环境变量
其中需要是 JAVA_HOME 跟 AXIS2_HOME
这些你都安装过了吗?追问

这些我都安装过了,在cmd中运行如上。大侠能帮忙解决一下不,tomcat的bat文件也运行不了,一闪就没有了。

追答

你安装过Java运行机嘛?Java安装到哪个目录里面了?
set JAVA_HOME="这里写上你Java安装的目录\bin"
然后再运行这个bat脚本。
应该还有一个axis2 home
set AXIS2_HOME="G:\LanguageSoftWare\axis2\"

本回答被网友采纳
第2个回答  2013-01-04
可能是安全软件的问题吧,你安全软件都退出,然后用管理员身份执行一下,看看行不行~
相似回答