Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Batch files with timeout with no press any key to continue

Tags:

batch-file

When writing a batch file to change my IP Address to Static I have created this working script but right now it shows

Changing IP address  
Waiting for "2" seconds and press any key to continue    
Changing Gateway      
Waiting for "2" seconds and press any key to continue   
Changing Subnet   
waiting for "2" seconds and press any key to continue

The way I want it to show is

Changing IP address    
Sits 2 seconds with no display of text  
Changing Gateway  
Sits 2 seconds with no display of text  
Changing subnet  
Sits 2 seconds with no display of text

Right now I'm using the timeout command

Below is a snippet of code

@ECHO IP Address Changed  
timeout 2  
@ECHO Subnet Changed.....  
timeout 2  
@ECHO Gateway Changed....  
timeout 2  

Anyone know how to do this with the timeout command or another command.. I'm just looking for it to look like it's changing each area 1 at a time


1 Answers

Use the following:

timeout /T 2 /NOBREAK > nul

The > nul part redirects the output to the Null device, hence suppressing it. The /NOBREAK option prevents the wait time to be interrupted by any key presses.

like image 131
aschipfl Avatar answered Sep 08 '25 00:09

aschipfl