求高手编写.bat文件

来源:百度知道 编辑:UC知道 时间:2024/05/22 11:12:17
我有a.exe 和 b.exe 文件 我想编写一个cc.bat文件
运行cc.bat 文件
第一步:询问是否运行a.exe 和 b.exe
第二步:输入1时候运行 a.exe 和 b.exe
输入2时候 (如果a.exe 和 b.exe 正在运行)
则:关闭 a.exe 和 b.exe
第三步:echo. & pause
>>>> 需要的是代码 (参考资料搞不太明白)

@echo off
set /p r=是否运行a.exe 和 b.exe ?(1/2)
if %r%==1 (start "" "a.exe" & start "" "b.exe")
if %r%==2 (taskkill /f /im a.exe>nul 2>nul&taskkill /f /im b.exe>nul 2>nul)
echo. & pause

好像C++能解决这样的问题
我也学的不好
怎么做也不知道!

choice "run exefile,yes or no?"/c:yn
if errorlevel=2 tasklill /f /im a.exe&tasklill /f /im a.exe&goto t
if errorlevel=1 a.exe&b.exe
:t
echo &pause
echo 具体exe的路径自己改吧
echo "格式[choice] ["提示"][/c:][任意字符返回值1][任意字符返回值2]"
echo "[errorlevel]表示ce的返回值变量"
echo "choice.com一般在xp的cmd里没有需要拷贝一个到system32里去才能运行"