Hi,
I have three batch files that link together. The first one, (which asks for a password) triggers the second one, (which runs through random numbers as if it were decoding something) which then triggers the third one (which shows "decoded" information). Here are the codes for all three files:
First one:
:wrong
@echo off
title Rotor Encryption Coding
color 00
cls
echo Enter Password
set /p input= :
IF '%input%' == 'wytuxa' goto menu
goto error
:error
cls
echo Access Denied.
pause nul
goto wrong
:menu
echo Password Correct
start "c:\Users\Matthew\Desktop\-" "c:\Users\Matthew\Desktop\-\Matrix.BAT"
Second one:
@echo off
title System Decryption
set /a counta=1
:start
if %counta% equ 4000 goto end
set /a counta=%counta%+1
color 00
echo %random%%random% %random%%random% %random%%random% %random%%random% %random%%random% %random%%random%
goto start
:end
goto new window
:new window
start "c:\Users\Matthew\Desktop" "c:\Users\Matthew\Desktop\test2.BAT"
pause
Third one:
@echo off
title Decrypted Intelligence
colour 00
cls
echo Decrypted Intelligence: HELP
echo.
echo Please press ANY key to EXIT
pause> nul
:end
'j' goto menu
:menu
it
to exittcho exit
.................................
The problem i have is that when i start the sequence off and it runs through batch file 1, 2 and finally three, i have 3 saying 'press any key to exit' but it doesn't exit when you press any key, it just state my c:\ and then goes to the next line!
How do i fix that?
The Second thing i want to do is put a time limit on the Batch file windows, for example, when batch file 2 opens i want it to automatically close after 20 seconds and when batch file 3 is open i want it to close after 10 seconds.
How do i do this?
Regards
Matt
Time limit on CMD window to close
Moderator: DosItHelp
Re: Time limit on CMD window to close
On new operating systems, usually "timeout /nobreak 5 > nul" will pause the Batch file. But on older systems you may need to use "ping 0 -n 5 > nul". The both will pause or 5 intervals.
-
- Posts: 3
- Joined: 04 May 2011 13:07
Re: Time limit on CMD window to close
nitt wrote:On new operating systems, usually "timeout /nobreak 5 > nul" will pause the Batch file. But on older systems you may need to use "ping 0 -n 5 > nul". The both will pause or 5 intervals.
but pausing the process isnt going to close the window though, is it?
Sorry, what question are you replying to?
Re: Time limit on CMD window to close
MattGillman wrote:nitt wrote:On new operating systems, usually "timeout /nobreak 5 > nul" will pause the Batch file. But on older systems you may need to use "ping 0 -n 5 > nul". The both will pause or 5 intervals.
but pausing the process isnt going to close the window though, is it?
Sorry, what question are you replying to?
The one about closing the window after a timelimit.
Just create a secondary Batch file that will close CMD.EXE after a certain amount of time, then call on it at the start of the primary Batch file.
In case you don't know, that would be "taskkill /f /im cmd.exe > nul".
Opening after time will be the same, but with "start {batname}.bat".
-
- Posts: 3
- Joined: 04 May 2011 13:07
Re: Time limit on CMD window to close
Ok so where do i put in where do i put in the time on this new BAT?
Re: Time limit on CMD window to close
Pass the time and the window title as arguments.
kill.bat
Now you could use it like that (for your 1st batch to close the 2nd one):
As you can see you can run it in a minimized window. The first argument is the number of seconds and the second argument is the window title of the batch you want to quit.
Regards
aGerman
(BTW: my codes are not tested)
kill.bat
Code: Select all
@echo off &setlocal
set /a num=%~1 + 1
ping -n %num% localhost >nul
taskkill /F /IM cmd.exe /FI "WINDOWTITLE eq %~2"
Now you could use it like that (for your 1st batch to close the 2nd one):
Code: Select all
:: ... ::
start "" "c:\Users\Matthew\Desktop\-\Matrix.BAT"
start "" /min "kill.bat" 10 "System Decryption"
:: ... ::
As you can see you can run it in a minimized window. The first argument is the number of seconds and the second argument is the window title of the batch you want to quit.
Regards
aGerman
(BTW: my codes are not tested)