批处理学习(别人的bat)

来源:互联网 发布:eclipse mac 图标小 编辑:程序博客网 时间:2024/05/17 21:07
批处理 作为 简单的脚本语言, 用起来相当方便, 之前 需要 给程序批量修改渠道号 和 应用签名, 写了一个批量修改渠道号并且签名的bat, 
从开始的 不能区分start 和 call 命令, 到现在的稍微熟悉点, 花的时间不多 , 但是 一直不满意, 
所以, 有时间就先看下 批处理。
再重新修改下做的东西, 并且希望以后能多用它做一些简单的事情, 让平时的工作更方便点。




自己 找了个文档, 所有的学习都是从模仿开始, 自己有时间也收集下看见过的批处理文件 , 无论是简单的,还是复杂的。




----------------------------【proguard】----------------------------

android中自带的 运行混淆的 jar的 bat,  位于 %xxxxx%android-sdk\tools\proguard\bin\proguardgui.bat


@ECHO OFFREM Start-up script for the GUI of ProGuard -- free class file shrinker,REM optimizer, obfuscator, and preverifier for Java bytecode.REMREM Note: when passing file names containing spaces to this script,REM       you'll have to add escaped quotes around them, e.g.REM       "\"C:/My Directory/My File.txt\""IF EXIST "%PROGUARD_HOME%" GOTO homeSET PROGUARD_HOME=..:homejava -jar "%PROGUARD_HOME%"\lib\proguardgui.jar %*

用 if  和 goto  来 调整运行的顺序, 用 java -jar 来调用proguardgui.jar文件

如果没有设置"%PROGUARD_HOME%", 就设置为 父目录。


············

位于 %xxxxx%android-sdk\tools\proguard\bin\retrace.bat

@ECHO OFFREM Start-up script for Retrace -- companion tool for ProGuard, free class fileREM shrinker, optimizer, obfuscator, and preverifier for Java bytecode.REMREM Note: when passing file names containing spaces to this script,REM       you'll have to add escaped quotes around them, e.g.REM       "\"C:/My Directory/My File.txt\""IF EXIST "%PROGUARD_HOME%" GOTO homeSET PROGUARD_HOME=..:homejava -jar "%PROGUARD_HOME%"\lib\retrace.jar %*


···········

位于 %xxxxx%android-sdk\tools\proguard\bin\proguard.bat

@ECHO OFFREM Start-up script for ProGuard -- free class file shrinker, optimizer,REM obfuscator, and preverifier for Java bytecode.REMREM Note: when passing file names containing spaces to this script,REM       you'll have to add escaped quotes around them, e.g.REM       "\"C:/My Directory/My File.txt\""IF EXIST "%PROGUARD_HOME%" GOTO homeSET PROGUARD_HOME=..:homejava -jar "%PROGUARD_HOME%"\lib\proguard.jar %*


```````````````

几个都是类似的功能。




----------------------------【tomcat】----------------------------

位于tomcatxx/bin/service.bat

@echo offrem Licensed to the Apache Software Foundation (ASF) under one or morerem contributor license agreements.  See the NOTICE file distributed withrem this work for additional information regarding copyright ownership.rem The ASF licenses this file to You under the Apache License, Version 2.0rem (the "License"); you may not use this file except in compliance withrem the License.  You may obtain a copy of the License atremrem     http://www.apache.org/licenses/LICENSE-2.0remrem Unless required by applicable law or agreed to in writing, softwarerem distributed under the License is distributed on an "AS IS" BASIS,rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.rem See the License for the specific language governing permissions andrem limitations under the License.if "%OS%" == "Windows_NT" setlocalrem ---------------------------------------------------------------------------rem NT Service Install/Uninstall scriptremrem Optionsrem install                Install the service using Tomcat7 as service name.rem                        Service is installed using default settings.rem remove                 Remove the service from the System.remrem name        (optional) If the second argument is present it is consideredrem                        to be new service nameremrem $Id: service.bat 1000718 2010-09-24 06:00:00Z mturk $rem ---------------------------------------------------------------------------set "SELF=%~dp0%service.bat"rem Guess CATALINA_HOME if not definedset "CURRENT_DIR=%cd%"if not "%CATALINA_HOME%" == "" goto gotHomeset "CATALINA_HOME=%cd%"if exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHomerem CD to the upper dircd ..set "CATALINA_HOME=%cd%":gotHomeif exist "%CATALINA_HOME%\bin\tomcat7.exe" goto okHomeecho The tomcat.exe was not found...echo The CATALINA_HOME environment variable is not defined correctly.echo This environment variable is needed to run this programgoto end:okHomerem Make sure prerequisite environment variables are setif not "%JAVA_HOME%" == "" goto gotJdkHomeif not "%JRE_HOME%" == "" goto gotJreHomeecho Neither the JAVA_HOME nor the JRE_HOME environment variable is definedecho Service will try to guess them from the registry.goto okJavaHome:gotJreHomeif not exist "%JRE_HOME%\bin\java.exe" goto noJavaHomeif not exist "%JRE_HOME%\bin\javaw.exe" goto noJavaHomegoto okJavaHome:gotJdkHomeif not exist "%JAVA_HOME%\jre\bin\java.exe" goto noJavaHomeif not exist "%JAVA_HOME%\jre\bin\javaw.exe" goto noJavaHomeif not exist "%JAVA_HOME%\bin\javac.exe" goto noJavaHomeif not "%JRE_HOME%" == "" goto okJavaHomeset "JRE_HOME=%JAVA_HOME%\jre"goto okJavaHome:noJavaHomeecho The JAVA_HOME environment variable is not defined correctlyecho This environment variable is needed to run this programecho NB: JAVA_HOME should point to a JDK not a JREgoto end:okJavaHomeif not "%CATALINA_BASE%" == "" goto gotBaseset "CATALINA_BASE=%CATALINA_HOME%":gotBaseset "EXECUTABLE=%CATALINA_HOME%\bin\tomcat7.exe"rem Set default Service nameset SERVICE_NAME=Tomcat7set PR_DISPLAYNAME=Apache Tomcat 7if "x%1x" == "xx" goto displayUsageset SERVICE_CMD=%1shiftif "x%1x" == "xx" goto checkServiceCmd:checkUserif "x%1x" == "x/userx" goto runAsUserif "x%1x" == "x--userx" goto runAsUserset SERVICE_NAME=%1set PR_DISPLAYNAME=Apache Tomcat %1shiftif "x%1x" == "xx" goto checkServiceCmdgoto checkUser:runAsUsershiftif "x%1x" == "xx" goto displayUsageset SERVICE_USER=%1shiftrunas /env /savecred /user:%SERVICE_USER% "%COMSPEC% /K \"%SELF%\" %SERVICE_CMD% %SERVICE_NAME%"goto end:checkServiceCmdif /i %SERVICE_CMD% == install goto doInstallif /i %SERVICE_CMD% == remove goto doRemoveif /i %SERVICE_CMD% == uninstall goto doRemoveecho Unknown parameter "%1":displayUsageecho.echo Usage: service.bat install/remove [service_name] [/user username]goto end:doRemoverem Remove the service"%EXECUTABLE%" //DS//%SERVICE_NAME%if not errorlevel 1 goto removedecho Failed removing '%SERVICE_NAME%' servicegoto end:removedecho The service '%SERVICE_NAME%' has been removedgoto end:doInstallrem Install the serviceecho Installing the service '%SERVICE_NAME%' ...echo Using CATALINA_HOME:    "%CATALINA_HOME%"echo Using CATALINA_BASE:    "%CATALINA_BASE%"echo Using JAVA_HOME:        "%JAVA_HOME%"echo Using JRE_HOME:         "%JRE_HOME%"rem Use the environment variables as an examplerem Each command line option is prefixed with PR_set PR_DESCRIPTION=Apache Tomcat 7.0.34 Server - http://tomcat.apache.org/set "PR_INSTALL=%EXECUTABLE%"set "PR_LOGPATH=%CATALINA_BASE%\logs"set "PR_CLASSPATH=%CATALINA_HOME%\bin\bootstrap.jar;%CATALINA_BASE%\bin\tomcat-juli.jar;%CATALINA_HOME%\bin\tomcat-juli.jar"rem Set the server jvm from JAVA_HOMEset "PR_JVM=%JRE_HOME%\bin\server\jvm.dll"if exist "%PR_JVM%" goto foundJvmrem Set the client jvm from JAVA_HOMEset "PR_JVM=%JRE_HOME%\bin\client\jvm.dll"if exist "%PR_JVM%" goto foundJvmset PR_JVM=auto:foundJvmecho Using JVM:              "%PR_JVM%""%EXECUTABLE%" //IS//%SERVICE_NAME% --StartClass org.apache.catalina.startup.Bootstrap --StopClass org.apache.catalina.startup.Bootstrap --StartParams start --StopParams stopif not errorlevel 1 goto installedecho Failed installing '%SERVICE_NAME%' servicegoto end:installedrem Clear the environment variables. They are not needed any more.set PR_DISPLAYNAME=set PR_DESCRIPTION=set PR_INSTALL=set PR_LOGPATH=set PR_CLASSPATH=set PR_JVM=rem Set extra parameters"%EXECUTABLE%" //US//%SERVICE_NAME% --JvmOptions "-Dcatalina.base=%CATALINA_BASE%;-Dcatalina.home=%CATALINA_HOME%;-Djava.endorsed.dirs=%CATALINA_HOME%\endorsed" --StartMode jvm --StopMode jvmrem More extra parametersset "PR_LOGPATH=%CATALINA_BASE%\logs"set PR_STDOUTPUT=autoset PR_STDERROR=auto"%EXECUTABLE%" //US//%SERVICE_NAME% ++JvmOptions "-Djava.io.tmpdir=%CATALINA_BASE%\temp;-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager;-Djava.util.logging.config.file=%CATALINA_BASE%\conf\logging.properties" --JvmMs 128 --JvmMx 256echo The service '%SERVICE_NAME%' has been installed.:endcd "%CURRENT_DIR%"


 

 


 


----------------------------xxx----------------------------



----------------------------xxx----------------------------



----------------------------xxx----------------------------






原创粉丝点击