A Windows XP help forum. PCbanter

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.

Go Back   Home » PCbanter forum » Microsoft Windows XP » General XP issues or comments
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

How do you make a batch file accept 1-char keyboard input WITHOUT having to also press carriage return?



 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old May 29th 18, 01:13 AM posted to alt.comp.os.windows-10,microsoft.public.windowsxp.general,alt.windows7.general
Bob J Jones
external usenet poster
 
Posts: 168
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off






All times are GMT +1. The time now is 10:44 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 PCbanter.
The comments are property of their posters.