If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
How do you make a batch file accept 1-char keyboard input WITHOUT having to also press carriage return?
How do you make a batch file accept single-character keyboard input
WITHOUT having to also press carriage return? This generic DOS network kill script works great to kill the network, for example, whenever you install programs that you don't want to phone home. https://www.liquidvpn.com/vpn-kill-switches/ All the DOS script does is disable and re-enable the router gateway (192.168.1.1) in the routing table. But it's a pain to always have to hit carriage return after pressing 1, 2, or 3. It would be nice if just pressing the 1, 2, or 3 (or "d" for disable and "e" for enable) worked in the script without the script needing the user to also press the carriage return. FILE: LiquidVPN-Kill-Switch.bat LOCATION: https://www.liquidvpn.com/billing/dl.php?type=d&id=49 Do you know DOS batch scripts well enough to tell us how to eliminate the need to press the carriage return after pressing the (1) to disable the gateway, the (2) to re-enable the gateway, or (3) to set the gateway? Here is a snippet of that code. set defgw=192.168.0.1 echo Your routers gateway is probably "%defgw%" echo -if nothing appears or its incorrect, add it manually (Press '3') echo. echo USAGE: echo. echo -Press "1" to Enable Kill Switch (IP "%defgw%") echo -Press "2" to Disable Kill Switch (IP "%defgw%") echo -Press "3" to manually set default gateway if its not detected above. echo -Press "h" for Kill Switch Help echo -Press "x" to exit Kill Switch. echo. set /p option=Your option: if '%option%'=='1' goto ption1 if '%option%'=='2' goto ption2 if '%option%'=='3' goto ption3 if '%option%'=='x' goto :exit if '%option%'=='h' goto :help echo Insert 1, 2, x or h timeout 3 goto start ption1 route delete 0.0.0.0 %defgw% echo Default gateway "%defgw%" removed timeout 3 goto start ption2 route add 0.0.0.0 mask 0.0.0.0 %defgw% echo Defaulte gateway "%defgw%" restored timeout 3 goto start ption3 echo set /p defgw=your gw IP (e.g. 192.168.0.1): goto start :help cls How do you make a batch file accept single-character keyboard input WITHOUT having to also press carriage return? |
Thread Tools | |
Display Modes | |
|
|