用法:在%1给出bat文件名
会自动用指定的编辑器打开BAT文件,只要一保存就会自动运行,
省去了多次打开cmd,和在窗口间切换来切换去的。
"c:\notepad.exe" 可以自己选一个喜欢的文本编辑器来用,又不影响原来的notepad.exe
再建一个快捷方式,并加上快捷键,用起来还真的挺方便的,呵呵!
想法来源于:批处理之家 qqjue 的《用UltraEdit创建批处理编译环境》
::用法:在%1给出bat文件名
@echo off
set "tit=[批处理自动测试器] "
set ece=%tit%
set tg=
set file=
popd&title %tit%请给出文件名,支持拖放
if "%~x1" neq ".bat" (set/p file=%tg%输入要编辑的批处理文件名:) else (goto :begin)
:agin
if not defined file goto :eof
if /i "%file:~-4%" neq ".bat" set file=%file%.bat
%0 %file%
:begin
echo;
pushd "%~dp1"
if not exist %1 (echo @echo off^&setlocal enabledelayedexpansion>%1)
set ran=%random%
echo. >%temp%\bat.bat%ran%
start /b cmd.exe /c notepad.exe %1^&del %temp%\bat.bat%ran%
title %tit%当前文件:%1
:loop
set "att=%~a1"
if "%att:a=%" neq "%att%" (
set/p=%tg% 运行"%1"<nul
echo;&echo;
start /i cmd.exe /k "%1" ^&pause^&exit
attrib "%1" -a
) else (ping -n 2 127.1 >nul)
if not exist %temp%\bat.bat%ran% %0
set/p=%tg% %ece%<nul
set ece=%ece:~1%%ece:~0,1%
goto :loop
Last edited by netbenton on 2009-8-17 at 07:47 ]