I'm making a small "lazy sleep" .bat file for Windows 10, and it works well. Except I get a "missing operand" at the top of the cmd windows when I start the program : cmd windows when I start the program I'm a newbie at Batch, so don't be harsh. I already went online but nothing matches my problem, and nothing I tried seems to fix it.
Here is my code (in French, sorry) :
@echo off
Rem 65001 for Unicode, 850 or 863 doesn't seem to work for French accents
chcp 65001
:annuler
set /a txt1=""
set /a tmp=0
set /p txt1="Veuillez préciser une unité : (h)eures, (m)inutes ou (s)econdes. (a)nnuler pour sortir du programme. "
IF /i "%txt1%"=="a" goto sortie
IF /i "%txt1%"=="h" goto heures
IF /i "%txt1%"=="m" goto minutes
IF /i "%txt1%"=="s" goto secondes
:heures
set /p tmp="Dans combien d'heures souhaitez-vous mettre en veille prolongée ? 0 pour annuler : "
IF /i "%tmp%"=="0" goto annuler
set /a dur=tmp*3600
timeout /t %dur%&&rundll32.exe powrprof.dll,SetSuspendState Sleep
:minutes
set /p tmp="Dans combien de minutes souhaitez-vous mettre en veille prolongée ? 0 pour annuler : "
IF /i "%tmp%"=="0" goto annuler
set /a dur=tmp*60
timeout /t %dur%&&rundll32.exe powrprof.dll,SetSuspendState Sleep
:secondes
set /p tmp="Dans combien de secondes souhaitez-vous mettre en veille prolongée ? 0 pour annuler : "
IF /i "%tmp%"=="0" goto annuler
set /a dur=tmp
timeout /t %dur%&&rundll32.exe powrprof.dll,SetSuspendState Sleep
:sortie
pause
The question is "enter a unit (hour, minute, second) and then enter the value for the timer to got o sleep mode".
"annuler" means "cancel" "sortie" means "exit"
Thanks for any help you can bring.