Batch file pentru inchiderea calculatorului cu numaratoare inversa si voce

Configurare noua (How To)

Situatie

Urmatorul batch se poate utiliza pentru inchiderea automata a calculatorului. Numaratoarea inversa incepe de la 15 secunde, asistata prin voce.

1. Deschideti notepad sau orice alt editor de text
2. Copiati codul de mai jos:

@echo off
Title Countdown for shutdown
Mode con Cols=67 lines=4 & Color 0A
set /a num=15
:start
echo(
echo Would you like to shutdown your computer in 15 seconds ? (Y/N) ?
Call:Speak “Would you like to shutdown your computer in 15 seconds ?”
set /p “INPUT=”

If /i “%INPUT%” == “y” goto yes
If /i “%INPUT%” == “n” goto no
Exit /b

:yes
cls
echo(
echo Process and Services will be automatically stop after %num% seconds..
Call:Speak “Process and Services will be automatically stop after %num% seconds..”
Goto Countdown

:CountDown
cls
echo(
echo Process and Services will be automatically stop after %num% seconds..
Call:Speak “%num% !”
Timeout /T 1 /NoBreak >nul
set /a num=num-1
if %num% GTR -1 goto :CountDown
goto shutdown

:no
exit

:Speak <msg>
(
echo Set sapi=Createobject(“sapi.spvoice”^)
echo sapi.Speak(“%~1″^)
)>”%tmp%\%~n0.vbs”
Cscript /nologo “%tmp%\%~n0.vbs”
Del “%tmp%\%~n0.vbs”
exit /b

:Shutdown
Call:Speak “We Shutdown the computer !”
shutdown /h

Daca dorim sa modificam timpul. De ex: 4 secundem, modificam urmatoarele:

set /a num=4
echo Would you like to shutdown your computer in 4 seconds ? (Y/N) ?
Call:Speak “Would you like to shutdown your computer in 4 seconds ?”

3. Salvati fisierul cu extensia .bat sau .cmd
4. Il puteti adapta dupa nevoile voastre.

Solutie

Tip solutie

Permanent

Voteaza

(14 din 28 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?