- 帖子
- 4
- 积分
- 44
- 技术
- 0
- 捐助
- 0
- 注册时间
- 2009-6-16
|
源码
@echo off&setlocal enabledelayedexpansion
mode con cols=50 lines=10&color 1f
title 幸运抽奖软件 made by batman
for /f "delims=" %%i in (num.txt) do set /a total+=1
set "m=0"&echo 中奖名单:>name.txt
:begin
for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do set "pid=%%i"&goto next
:next
cls&echo.&echo ========^> 幸运抽奖 ^<========
echo.&echo 总共有%total%人参与抽奖
echo.&set /p num= 请输入奖项数量(1-10):
echo %num%|findstr "[^0-9]">nul&&goto next
if %num% geq 1 if %num% leq 10 goto contin
goto next
:contin
set "codes=一二三四五六七八九十"
set "code=!codes:~,%num%!"&set "n=1"
:lp
set "a%n%=%code:~,1%"
cls&echo.&echo.&echo.
set /p num%n%= 请输入!a%n%!等奖要抽取的人数:
echo !num%n%!|findstr "[^0-9]">nul&&goto lp
set /a totals+=num%n%
if %totals% geq %total% goto lp
set "code=%code:~1%"&set /a n+=1
if defined code goto lp
cls&set /a n-=1
for /l %%i in (1,1,%n%) do (
echo.&echo 设定!a%%i!等奖!num%%i!名
set "code1=!a%%i!!code1!"&set "code2=!num%%i!!code2!"
)
echo.&echo 请按任意键开始抽奖&pause>nul
:again
start lp.exe&set /a v=%code2:~,1%-m
cls&echo.&echo 已抽取%code1:~,1%等奖%m%名,还剩余%v%名
echo.&echo 名单正在滚动中...
echo.&echo 请按任意键抽取%code1:~,1%等奖&pause>nul
for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do (
if "%%i" neq "%pid%" taskkill /pid %%i /f>nul 2>nul
)
:loop
set /a a=%random%%%%total%+1,n=0
for /f "delims=" %%i in (num.txt) do (
set /a n+=1
if !n! equ %a% (
findstr "%%i" name.txt>nul&&goto loop||set "str=%%i"
)
)
cls&echo.&echo.&echo.&echo 本次抽取的%code1:~,1%等奖获得者是:%str%
echo %code1:~,1%等奖:%str%>>name.txt
set var=%var% %str%&set /a m+=1
ping /n 2 127.1>nul
if %m% neq %code2:~,1% goto again
cls&echo.&echo.&echo %code1:~,1%等奖获得者:
echo.&echo %var:~1%
echo.&echo 所有%code1:~,1%等奖已抽取完毕,按键继续
pause>nul
set "code1=%code1:~1%"&set "code2=%code2:~1%"
if defined code1 set "m=0"&set "var="&goto again
echo.&echo 所有奖项已抽取完毕,请按任意键退出
pause>nul
start name.txt
@echo off&setlocal enabledelayedexpansion
mode con cols=50 lines=10&color 1f
title 幸运抽奖软件 made by batman
for /f "delims=" %%i in (num.txt) do set /a total+=1
set "m=0"&echo 中奖名单:>name.txt
:begin
for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do set "pid=%%i"&goto next
:next
cls&echo.&echo ========^> 幸运抽奖 ^<========
echo.&echo 总共有%total%人参与抽奖
echo.&set /p num= 请输入奖项数量(1-10):
echo %num%|findstr "[^0-9]">nul&&goto next
if %num% geq 1 if %num% leq 10 goto contin
goto next
:contin
set "codes=一二三四五六七八九十"
set "code=!codes:~,%num%!"&set "n=1"
:lp
set "a%n%=%code:~,1%"
cls&echo.&echo.&echo.
set /p num%n%= 请输入!a%n%!等奖要抽取的人数:
echo !num%n%!|findstr "[^0-9]">nul&&goto lp
set /a totals+=num%n%
if %totals% geq %total% goto lp
set "code=%code:~1%"&set /a n+=1
if defined code goto lp
cls&set /a n-=1
for /l %%i in (1,1,%n%) do (
echo.&echo 设定!a%%i!等奖!num%%i!名
set "code1=!a%%i!!code1!"&set "code2=!num%%i!!code2!"
)
echo.&echo 请按任意键开始抽奖&pause>nul
:again
start lp.exe&set /a v=%code2:~,1%-m
cls&echo.&echo 已抽取%code1:~,1%等奖%m%名,还剩余%v%名
echo.&echo 名单正在滚动中...
echo.&echo 请按任意键抽取%code1:~,1%等奖&pause>nul
for /f "tokens=2 delims= " %%i in ('tasklist^|findstr "cmd.exe"') do (
if "%%i" neq "%pid%" taskkill /pid %%i /f>nul 2>nul
)
:loop
set /a a=%random%%%%total%+1,n=0
for /f "delims=" %%i in (num.txt) do (
set /a n+=1
if !n! equ %a% (
findstr "%%i" name.txt>nul&&goto loop||set "str=%%i"
)
)
cls&echo.&echo.&echo.&echo 本次抽取的%code1:~,1%等奖获得者是:%str%
echo %code1:~,1%等奖:%str%>>name.txt
set var=%var% %str%&set /a m+=1
ping /n 2 127.1>nul
if %m% neq %code2:~,1% goto again
cls&echo.&echo.&echo %code1:~,1%等奖获得者:
echo.&echo %var:~1%
echo.&echo 所有%code1:~,1%等奖已抽取完毕,按键继续
pause>nul
set "code1=%code1:~1%"&set "code2=%code2:~1%"
if defined code1 set "m=0"&set "var="&goto again
echo.&echo 所有奖项已抽取完毕,请按任意键退出
pause>nul
start name.txt
|
|