Help...help...help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Message
Author
Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Help...help...help

#1 Post by Kalop » 21 Nov 2011 22:07

Hi....
I have a batch file which start uTorrent with the warning remaining about connecting external drive with the utorrents files.
This is to remind and prevent the start of application, because if I start utorrent without external hard drive the utorrent application can't find the correct directory and all file are reported as falls. When finally drive is connected it is required to make recheck which take a long time to finalize. Before finish that task it is impossible to use application in any form.
This is the batch:
****************************************************************
@echo off
@echo off

color C
echo ------------------------------------------------
echo Did you connect external DRIVE for uTorrents ???
echo ------------------------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
set /pbang= Please select and press ENTER - Option:
if %bang%==1 goto 1
if %bang%==2 goto 3


echo -----

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
set /pbang= Please select and press ENTER - Option:
if %bang%==1 goto 4
if %bang%==2 goto 5


:3
CLS
echo.
echo.
echo.
echo -----------------------------------------------------
echo Please connect external DRIVE with uTorrent files
echo -----------------------------------------------------
pause
CLS
color E
echo --------------
echo and try again
echo --------------
pause
CLS
Exit

:4
Start C:\>c:\BatchuTorrentLink
Start c:\BatchuTorrentLink\uTorrent.exe

:5
CLS
Exit


*******************************************************
Everything it seems to work correctly expect one little hiccup at the end of section with this options:
******************
:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
set /pbang= Please select and press ENTER - Option:
if %bang%==1 goto 4
if %bang%==2 goto 5
***************************
option with key 1 and 2 works correctly but I have notice that if I choose just any other key on keyboard and "ENTRY", still it make selection to run the final and requested .exe file
I was trying to find solution to prevent that but unfortunately without success.
Now at the end I have just notice that similar situation specially with pressing "any key on keyboard" apply as well to section at beginning.
It is not a very important, but it bothers me to find out how it can be done covering practically every situation.

Thanks for help,

Kalop :cry: :? :oops:

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: Help...help...help

#2 Post by trebor68 » 21 Nov 2011 22:44

You have two different key results (1 and 2). But there are possible three different results (1, 2 and any other key).

Code: Select all

@echo off
:here1
echo ##
echo 1 - Option 1
echo 2 - Option 2
echo.
set /pbang=Select and press ENTER:
if %bang%==1 goto :opt1
if %bang%==2 goto :opt2
goto here1
:opt1
echo.
echo Option ONE is selected.
echo.
goto :eof
:opt2
echo.
echo Option TWO is selected.
echo.

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#3 Post by Kalop » 22 Nov 2011 00:22

Thanks trebor68 for quick replay.
I apologies for trouble, but were precisely I should add your lines o make it works?

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Help...help...help

#4 Post by renzlo » 22 Nov 2011 01:02

Hi Kalop,

You need to filter their choices or you might want to use choice commands. I've modified your code a bit. Please try:

****************************************************************

Code: Select all

@echo off
@echo off

color C
echo ------------------------------------------------
echo Did you connect external DRIVE for uTorrents ???
echo ------------------------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu1
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu1
if %bang%==1 goto 1
if %bang%==2 goto 3


echo -----

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if %bang%==1 goto 4
if %bang%==2 goto 5


:3
CLS
echo.
echo.
echo.
echo -----------------------------------------------------
echo Please connect external DRIVE with uTorrent files
echo -----------------------------------------------------
pause
CLS
color E
echo --------------
echo and try again
echo --------------
pause
CLS
Exit

:4
Start C:\>c:\BatchuTorrentLink
Start c:\BatchuTorrentLink\uTorrent.exe

:5
CLS
Exit


-renzlo

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#5 Post by Kalop » 22 Nov 2011 01:25

thanks -renzlo

There is nearly 100% improvement, but still when I choose option 1 for
"echo Did you connect external DRIVE for uTorrents ???"
and get to second menu wit
"echo Do you want to start uTorrent ???"
it can still open .exe file after I press "ENTER" key without making any chooses

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Help...help...help

#6 Post by renzlo » 22 Nov 2011 01:38

if that's the case, try this:

Code: Select all

@echo off

color C
echo ------------------------------------------------
echo Did you connect external DRIVE for uTorrents ???
echo ------------------------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu1
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu1
if not defined bang goto menu1
if %bang%==1 goto 1
if %bang%==2 goto 3


echo -----

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if not defined bang goto menu2
if %bang%==1 goto 4
if %bang%==2 goto 5


:3
CLS
echo.
echo.
echo.
echo -----------------------------------------------------
echo Please connect external DRIVE with uTorrent files
echo -----------------------------------------------------
pause
CLS
color E
echo --------------
echo and try again
echo --------------
pause
CLS
Exit

:4
Start C:\>c:\BatchuTorrentLink
Start c:\BatchuTorrentLink\uTorrent.exe

:5
CLS
Exit


-renzlo

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#7 Post by Kalop » 22 Nov 2011 01:50

sorry, no change. Still "entry" before any options opens file

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#8 Post by Kalop » 22 Nov 2011 02:00

yes, problem is that when key "Enter: is press is producing opening .exe file.
The must be something what can stop that after pressing Enter, and send it into the loop with menu2

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#9 Post by Kalop » 22 Nov 2011 02:28

Simple


I just add one line between:

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if not defined bang goto menu2

goto 5

if %bang%==1 goto 4
if %bang%==2 goto 5

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#10 Post by Kalop » 22 Nov 2011 02:33

no it dosen't work.
GIVE UP

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Help...help...help

#11 Post by renzlo » 22 Nov 2011 02:47

How about this:

Code: Select all

@echo off

color C
echo ------------------------------------------------
echo Did you connect external DRIVE for uTorrents ???
echo ------------------------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
:menu1
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu1
if not defined bang goto menu1
if %bang%==1 goto 1
if %bang%==2 goto 3


echo -----

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
goto :eof

:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if not defined bang goto menu2
if %bang%==1 goto 4
if %bang%==2 goto 5


:3
CLS
echo.
echo.
echo.
echo -----------------------------------------------------
echo Please connect external DRIVE with uTorrent files
echo -----------------------------------------------------
pause
CLS
color E
echo --------------
echo and try again
echo --------------
pause
CLS
goto :eof

:4
Start C:\>c:\BatchuTorrentLink
Start c:\BatchuTorrentLink\uTorrent.exe
goto :eof

:5
CLS
goto :eof

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#12 Post by Kalop » 22 Nov 2011 04:36

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
goto :eof

:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if not defined bang goto menu2
if %bang%==1 goto 4
if %bang%==2 goto 5

in that section wit that dosen't let ypu to make chosse with option 1 and 2

renzlo
Posts: 116
Joined: 03 May 2011 19:06

Re: Help...help...help

#13 Post by renzlo » 22 Nov 2011 06:15

replace that section with this:

Code: Select all

:1
@echo off
CLS
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.

:menu2
set /p bang= Please select and press ENTER - Option:
echo("%bang%"|findstr /vrxc:"\"[1-2]\"" >nul &&goto menu2
if not defined bang goto menu2
if %bang%==1 goto 4
if %bang%==2 goto 5

Kalop
Posts: 14
Joined: 21 Nov 2011 21:31

Re: Help...help...help

#14 Post by Kalop » 22 Nov 2011 06:58

no...it dosen't work

it is very interesting because if you press "Enter" in the first instants .exe.file will start. (what shouldn't happened)
However if you first take Option 1 or 2 the process is working according to plan.
But if you just say by mistake first time in Option insert other key on keyboard expect 1 or 2 and hit "Enter" it will take you to the beginning of the process.
The difference only now is that if you press "Entry" the hole process is working as intended, that is shoutdown.
Now the question is how to in the first instant stop "Entry" preforming opening ,exe file. :x :x :x :x

trebor68
Posts: 146
Joined: 01 Jul 2011 08:47

Re: Help...help...help

#15 Post by trebor68 » 22 Nov 2011 11:28

Here your batch file with the new rows
I have only add the new lines.:

###########################
@echo off

:menu0
color C
echo ------------------------------------------------
echo Did you connect external DRIVE for uTorrents ???
echo ------------------------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
set bang=0
set /pbang= Please select and press ENTER - Option:
if %bang%==1 goto 1
if %bang%==2 goto 3
goto :menu0

echo -----

:1
@echo off
CLS
:menu1
color A
echo.
echo.
echo.
echo ---------------------------------
echo Do you want to start uTorrent ???
echo ---------------------------------
echo.
echo MENU
echo ---------
echo 1= Yes
echo 2= No
echo.
set bang=0
set /pbang= Please select and press ENTER - Option:
if %bang%==1 goto 4
if %bang%==2 goto 5
goto :menu1


:3
CLS
echo.
echo.
echo.
echo -----------------------------------------------------
echo Please connect external DRIVE with uTorrent files
echo -----------------------------------------------------
pause
CLS
color E
echo --------------
echo and try again
echo --------------
pause
CLS
Exit

:4
Start C:\>c:\BatchuTorrentLink
Start c:\BatchuTorrentLink\uTorrent.exe

:5
CLS
Exit
###########################

Post Reply