View Single Post
  #28  
Old November 17th 18, 10:14 PM posted to microsoft.public.windowsxp.general
MikeS[_5_]
external usenet poster
 
Posts: 74
Default How do you make a batch file accept 1-char keyboard input WITHOUThaving to also press carriage return?

On 29/05/2018 02:19, wrote:
On Tue, 29 May 2018 00:13:59 +0000 (UTC), Bob J Jones
wrote:

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?


If you are really using DOS, you load ANSI.SYS and use the PROMPT
command to redefine keystrokes to command lines but I am not sure how
you do that after W/98.

If you can find a copy the real MSDOS CHOICE command will still work in
a cmd window. But not with 64 bit Windows 10 as it dates back to 16 bit
days.

Ads