Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch file problems, concerning files  (Read 5119 times)

0 Members and 1 Guest are viewing this topic.

Chobby

  • Guest
Batch file problems, concerning files
« on: November 19, 2005, 03:00:36 PM »
Okay .. Here it is:

I just started messing around with batch files etc, and i just ran into a problem ..
I've made a fine menu (according to myself ;)), from wich i can execute some programs ..

I write for instance 1 and then i hit enter, and winamp opens .. No problems there..
I've set it to go back to the front menu, when i've launched one of the programs .. And when i hit for instance 3 it starts rcon, and it says RCON IS LOADING, which is fine ..
But then after like 5 seconds i would want it to go back to main menu .. But, it doesn't .. I have to shut down rcon, before it goes back..

Is there any kind of command i can put in to make it go back after like 5 seconds, and not when the program is shutted down again?
You got my problem?

bil

  • Guest
Re: Batch file problems, concerning files
« Reply #1 on: November 20, 2005, 08:02:47 AM »
well i think if you  post your script it would be easy to figure out besides just guessing whats wrong.

Chobby

  • Guest
Re: Batch file problems, concerning files
« Reply #2 on: November 20, 2005, 02:17:40 PM »
@ECHO off
:start
CLS
ECHO /     Welcome
ECHO \     Choose a number below
ECHO /     and hit enter..
ECHO \    
ECHO /     1. Start winamp
ECHO \     2. Start lectio
ECHO /     3. Start rcon
ECHO \     4. Start xfire
ECHO /     5. Start Ad-Aware
ECHO \     6. Start explorer
ECHO /     7. Start PeerGuardian
ECHO \     8. Start Photoshop
ECHO /     9. Start Spybot
ECHO \     10. Start avast!
ECHO /     11. Exit
set choice=
set /p choice=Type the number to print text.      
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto ONE
if '%choice%'=='2' goto TWO
if '%choice%'=='3' goto THREE
if '%choice%'=='4' goto FOUR
if '%choice%'=='5' goto FIVE
if '%choice%'=='6' goto SIX
if '%choice%'=='7' goto SEVEN
if '%choice%'=='8' goto EIGHT
if '%choice%'=='9' goto NINE
if '%choice%'=='10' goto TEN
if '%choice%'=='11' goto end
ECHO "%choice%" is not valid please try again
ECHO.
goto start
:ONE
cls
ECHO WINAMP LOADING
win /m "C:\Program Files\Winamp\winamp.exe"
goto start
:TWO
cls
ECHO LECTIO LOADING
win /m "http://www.lectio.dk/lectio/54/SkemaGenerator.aspx?type=elev&id=1367103984"
goto start
:THREE
cls
ECHO RCON LOADING
win /m "C:\Program Files\Rcon Unlimited\Rcon Unlimited.exe"
goto start
:FOUR
cls
ECHO XFIRE LOADING
win /m "C:\Program Files\Xfire\Xfire.exe"
goto start
:FIVE
cls
ECHO AD-AWARE LOADING
win /m "C:\Program Files\Lavasoft\Ad-Aware SE Personal\Ad-Aware.exe"
goto start
:SIX
cls
ECHO EXPLORER LOADING
win /m "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
goto start
:SEVEN
cls
ECHO PEERGUARDIAN LOADING
win /m "C:\Program Files\PeerGuardian2\pg2.exe"
goto start
:EIGHT
cls
ECHO PHOTOSHOP CS2 LOADING
win /m "C:\Program Files\Graphics\Photoshop.exe"
goto start
:NINE
cls
ECHO SPYBOT LOADING
win /m "C:\Program Files\Spybot - Search & Destroy\SpybotSD.exe"
goto start
:TEN
cls
ECHO AVAST! ANTIVIRUS LOADING
win /m "C:\Program Files\Alwil Software\Avast4\ashAvast.exe"
goto start
:end

Okay .. i need it to go back to the main menu after it has done the ECHO <PROGRAM> LOADING .. After 5 seconds or such .. NOT when i close the program i chose to load..

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch file problems, concerning files
« Reply #3 on: November 21, 2005, 05:27:56 AM »
Try replacing win /m with the start command.

Ex:

start "C:\Program Files\Rcon Unlimited\Rcon Unlimited.exe"

The program will open in a separate address space and your batch file should continue back to the menu. (no 5 sec delay). If any of your options launch a 16-bit program, use the /separate switch with the start command to force a new address space.

Hope this helps. 8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein

Chobby

  • Guest
Re: Batch file problems, concerning files
« Reply #4 on: November 22, 2005, 01:04:23 AM »
Hmm .. now i think i did as you suggested .. But when i try to load a program i just get this:


It does go back to the main screen, yes, but it doesn't start the program  ???
So i thought ... got more ideas?  :P
It should be possible...

Heres the new code:
@ECHO off
:begin
CLS
ECHO /   Welcome
ECHO \   Choose a number below
ECHO /   and hit enter..
ECHO \    
ECHO /     1. Start winamp
ECHO \     2. Start lectio
ECHO /     3. Start rcon
ECHO \     4. Start xfire
ECHO /     5. Start Ad-Aware
ECHO \     6. Start explorer
ECHO /     7. Start PeerGuardian
ECHO \     8. Start Photoshop
ECHO /     9. Start Spybot
ECHO \     10. Start avast!
ECHO /     11. Exit
set choice=
set /p choice=Type the number to print text.      
if not '%choice%'=='' set choice=%choice:~0,1%
if '%choice%'=='1' goto ONE
if '%choice%'=='2' goto TWO
if '%choice%'=='3' goto THREE
if '%choice%'=='4' goto FOUR
if '%choice%'=='5' goto FIVE
if '%choice%'=='6' goto SIX
if '%choice%'=='7' goto SEVEN
if '%choice%'=='8' goto EIGHT
if '%choice%'=='9' goto NINE
if '%choice%'=='10' goto TEN
if '%choice%'=='11' goto end
ECHO "%choice%" is not valid please try again
ECHO.
goto begin
:ONE
cls
ECHO WINAMP LOADING
start "C:\Program Files\Winamp\winamp.exe"
goto begin
:TWO
cls
ECHO LECTIO LOADING
start "http://www.lectio.dk/lectio/54/SkemaGenerator.aspx?type=elev&id=1367103984"
goto begin
:THREE
cls
ECHO RCON LOADING
start "C:\Program Files\Rcon Unlimited\Rcon Unlimited.exe"
goto begin
:FOUR
cls
ECHO XFIRE LOADING
start "C:\Program Files\Xfire\Xfire.exe"
goto start
:FIVE
cls
ECHO AD-AWARE LOADING
start "C:\Program Files\Lavasoft\Ad-Aware SE Personal\Ad-Aware.exe"
goto begin
:SIX
cls
ECHO EXPLORER LOADING
start "C:\Program Files\Internet Explorer\IEXPLORE.EXE"
goto begin
:SEVEN
cls
ECHO PEERGUARDIAN LOADING
start "C:\Program Files\PeerGuardian2\pg2.exe"
goto begin
:EIGHT
cls
ECHO PHOTOSHOP CS2 LOADING
start "C:\Program Files\Graphics\Photoshop.exe"
goto begin
:NINE
cls
ECHO SPYBOT LOADING
start "C:\Program Files\Spybot - Search & Destroy\SpybotSD.exe"
goto begin
:TEN
cls
ECHO AVAST! ANTIVIRUS LOADING
start "C:\Program Files\Alwil Software\Avast4\ashAvast.exe"
goto begin
:end
end

Sidewinder



    Guru

    Thanked: 139
  • Experience: Familiar
  • OS: Windows 10
Re: Batch file problems, concerning files
« Reply #5 on: November 22, 2005, 05:04:15 PM »
Many (if not most) Windows programs have components that must be loaded with the main program

Code: [Select]

:NINE
cls
ECHO SPYBOT LOADING
cd /d "C:\Program Files\Spybot - Search & Destroy"
start SpybotSD.exe
goto start


The strange thing is that the START works fine from the command line (go figure). I picked option nine since that was the only program we had in common but changes will have to be made for all the options.

Note: options 10 & 11 will give unpredictable results since your IF NOT statement restricts the length of the prompt reply to one byte!!

Good luck.  8)
The true sign of intelligence is not knowledge but imagination.

-- Albert Einstein