|
petools.ini:
`生成目标文件的快捷方式
_SUB MAKELINK
ENVI DRVS=%DRVS% %TOOLS%
LSTR Drive=%TOOLS%,1
ENVI V0=%StartMenu%\%Drive%盘PETools
LINK %V0%\target,%TOOLS%
EXEC =!CMD /C "COPY "%WINDIR%\SYSTEM32\Desk.ini" "%V0%\Desktop.ini""
TEAM SITE %V0%\*.*,+A+H+S|SITE %V0%,+R+S|ENVI V0=
TEAM FORX %TOOLS%\*.INI,TOOLSINI,0,LOAD %TOOLSINI%|ENVI TOOLSINI=
_END
_SUB MAKE_LINK
ENVI DRVS=%DRVS% %TOOLS%
EXEC !CMD /C "PETOOLS_LINK %TOOLS%"
_END
`搜索PETOOLS目录下文件
ENVI DRVS=
`FORX @\PETOOLS,TOOLS,0,CALL MAKELINK
FORX @\PETOOLS,TOOLS,0,CALL MAKE_LINK
FIND $%DRVS%=,!MESS %DRVS%已经被装载到了开始菜单。@挂载PETOOLS工具 #OK *3000
====================================================
下面使用CHENALL的批处理
PETOOLS_LINK.cmd
::petools扩展目录搜索安装程序 by chenall
@echo off
if "%~1"=="" goto :eof
if not defined StartMenu SET "StartMenu=%USERPROFILE%\「开始」菜单"
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
echo.%1|find /i "\AutoRuns\" &&goto :eof
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
[ 本帖最后由 zhaohj 于 2010-5-5 17:34 编辑 ] |
|