|
原帖由 haiou327 于 2010-3-18 23:02 发表
是里面的CMD代码,不是文件里的PETOOLS
::PECMD FORX @\PETOOLS,TOOLS,0,!EXEC CMD /C "PETOOLS_LINK %TOOLS%"
@echo off
if "%~1"=="" goto :eof
if not defined StartMenu goto :eof
if "%~1"=="merge" goto :merge
if not exist "%~1" goto :eof
SET "BASE_DIR=%~1"
SET "外置程序=外置程序_%~d1盘"
SET "外置程序=%StartMenu%\%外置程序::=%"
SET "_TF=%WinDir%\T_PETOOLS_%base_dir:~0,1%_"
IF EXIST "%外置程序%" RD /S /Q "%外置程序%" 2>nul
:START
DEL "%_TF%*.*" 2>nul
PUSHD "%~F1"
>%_TF%LST.lst dir /s/a/b *.wim *.cmd *.bat *.exe readme*.txt 使用说明*.txt
POPD
PUSHD "%WinDir%"
for /f "usebackq delims=" %%i in (%_TF%LST.lst) do CALL :MAKE_LINK "%%i"
ECHO.EXEC !%~F0 merge "%外置程序%" >>%_TF%LNK.INI
ECHO.FILE %_TF%LNK.INI>>%_TF%LNK.INI
START PECMD LOAD %_TF%LNK.INI
PUSHD "%~F1"
>"%_TF%REG.lst" dir /s/a/b SETUP_REG.REG 2>nul
>"%_TF%INF.lst" dir /s/a/b setup.inf 2>nul
POPD
if exist "%_TF%REG.LST" for /f "usebackq delims=" %%i in ("%_TF%REG.LST") do REGEDIT /S "%%i"
if exist "%_TF%INF.lst" for /f "usebackq delims=" %%i in ("%_TF%INF.lst") do RUNDLL32.EXE SETUPAPI.DLL,InstallHinfSection DefaultInstall 128 %%i
IF EXIST "%_TF%SETUP.LST" for /f "usebackq delims=" %%i in ("%_TF%SETUP.LST") do CALL :PETOOLS_SETUP %%i
DEL %_TF%*.lst
POPD
goto :eof
:MAKE_LINK
SETLOCAL
if "%~1"=="" goto :eof
if /i "%~n1"=="setup" (
echo.%1 >>"%_TF%SETUP.LST"
goto :eof
)
SET ".=%~1"
SET ".=%.:&=^&%"
SET "PETOOLS=%~dpn1"
call,SET "PETOOLS=%%PETOOLS:%BASE_DIR%=%外置程序%%%"
SET "PETOOLS=%PETOOLS:&=^&%"
echo.LINK %PETOOLS%,%.%>>%_TF%LNK.INI
GOTO :EOF
:PETOOLS_SETUP
::为什么需要这些步骤呢,因为考虑到有一些批处理对执行目录的要求(编写时没有考虑到),所以才需要进入批处理目录执行.否则可能会出错.表面上是执行了,其实执行的结果是错误的.用PECMD调用同样会有这样的问题.
pushd "%~dp1"
PECMD EXEC !%~nx1
POPD
goto :eof
:merge
PUSHD %2||GOTO :EOF
for /d %%i in ("%~2\*") do call :merge_lnk "%%i"
POPD
goto :eof
:merge_lnk
CD /D %1||GOTO :EOF
for /d %%i in ("%~f1\*") do call %0 "%%i"
CD /D %1||GOTO :EOF
set n=
for /f %%i in ('dir /a/b') do (
if defined n goto :eof
set n=1
)
for /f "usebackq delims=" %%i in (`dir /a/b`) do move /y "%%i" ..\
cd..&&rd %1
goto :eof
==============================================================
请在上面的代码中用红色的标出,谢谢!! |
|