Reputation: 10111
i have this batch file, which makes constantly a loop. I want the user to be able to terminate it in the batch, not just clicking the X.
This is what i need (somehow):
@echo off
:proc
cls
rem All kind of stuff...
echo Hit any key to terminate...
sleep 1
@pause>nul
But, of course, sleep and pause can't work at the same time.
How is it possible?
Upvotes: 0
Views: 652
Reputation:
Remove the pause and change the message to "Hit Ctrl + C to terminate". Presumably the script has a "goto :proc" that you are not showing?
Upvotes: 4
Reputation: 31
More recent editions of Windows has the TIMEOUT command that does just this.
http://technet.microsoft.com/en-us/library/cc754891%28v=ws.10%29.aspx
Upvotes: 3