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

Author Topic: Running a program from BAT file make the dos window stuck and open  (Read 9022 times)

0 Members and 1 Guest are viewing this topic.

joker197cinque

  • Guest
I am writing a batch file but I am stuck at a (hope) simple step; if I write into the batch file:


"c:\program files\internet explorer\iexplore.exe"
echo done!


and I double click it, IE opens well, but the line echo done!! is not executed ... the window remains stuck at the IEXPLORE line ...

Example ------ > http://i42.tinypic.com/2r5t5af.gif

How can I do to run a  program and continue the execution ?

I tried >nul , start ... , but nothing worked.

Thanks for help.

[Saving space, attachment deleted by admin]

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Running a program from BAT file make the dos window stuck and open
« Reply #1 on: March 18, 2010, 09:08:48 AM »
To help you understand the issue, try this more simple thing:

TEST.BAT
Code: [Select]
START NOTEPAD.EXE
echo all done
pause
exit
That will not do what you might expect. The command line is not the way to start windows programs unless you wish to stay in the command line.
If you wish to start a Windows program from a script,  you need to use another form of script other that batch. Maybe VBScript
But if you really want to, it can be done in BATCH. But it is very awkward.
I will let somebody else explain it.

Salmon Trout

  • Guest
Re: Running a program from BAT file make the dos window stuck and open
« Reply #2 on: March 18, 2010, 02:26:41 PM »
The command line is not the way to start windows programs unless you wish to stay in the command line.

That's not really true. In fact it's not true at all. You are mistaking your lack of knowledge for a Windows limitation.

Quote
If you wish to start a Windows program from a script,  you need to use another form of script other that batch. Maybe VBScript
But if you really want to, it can be done in BATCH. But it is very awkward.

It's not "very awkward". At least that's my opinion. You just have to study the documentation of the START command. You can see this by opening a command window and typing START /? and hitting the ENTER key.

You will probably want to use this command if you want to start Internet Explorer and immediately return to the batch file

Code: [Select]
start "" "C:\Program Files\Internet Explorer\iexplore.exe"

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Running a program from BAT file make the dos window stuck and open
« Reply #3 on: March 18, 2010, 11:52:57 PM »
Unless you need special options (namely, waiting for the program to finish) , you can just start them without using "start". control returns to the batch file immediately, as it would in the case of start.

EDIT:

nevermind that... start appears to work differently wether it's run within a batch or at the prompt itself.
I was trying to dereference Null Pointers before it was cool.

Azzaboi



    Apprentice
  • Aaron's Game Zone
  • Thanked: 37
    • Aaron's Game Zone
  • Experience: Experienced
  • OS: Windows 7
Re: Running a program from BAT file make the dos window stuck and open
« Reply #4 on: March 19, 2010, 01:43:24 AM »
First of all make sure you are running it with Admin rights....

Quote
@echo off
echo starting IE
cd "C:\Program Files\Internet Explorer\"
call iexplore.exe
echo all done
pause

The 'call' will wait until the program has finished/closed before executing the rest of the batch file. It is waiting for any parameters/changes first.
The pause will leave it open until the user presses a key, so you can view your 'all done' message or any exceptions that occured.

Rather than calling you can use 'start' to not wait and continue the batch file while it's running as well:
Quote
start iexplore.exe

Now you can have fun writing your little virus...
« Last Edit: March 19, 2010, 01:57:51 AM by Azzaboi »
Aaron's Game Zone
The best free online flash games: http://azzaboi.weebly.com

Play Games - Play free games at Play Games Arcade

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Running a program from BAT file make the dos window stuck and open
« Reply #5 on: March 19, 2010, 09:27:37 AM »
Quote
Now you can have fun writing your little virus...
Are you thinking the OP is a wanna be virus creator?

Azzaboi



    Apprentice
  • Aaron's Game Zone
  • Thanked: 37
    • Aaron's Game Zone
  • Experience: Experienced
  • OS: Windows 7
Re: Running a program from BAT file make the dos window stuck and open
« Reply #6 on: March 19, 2010, 01:40:39 PM »
It was just a joke, but one of the reasons you would want a batch file to continue running after executing something rather than waiting for the user. lol anyways isn't IE a virus?
Aaron's Game Zone
The best free online flash games: http://azzaboi.weebly.com

Play Games - Play free games at Play Games Arcade

Geek-9pm


    Mastermind
  • Geek After Dark
  • Thanked: 1026
    • Gekk9pm bnlog
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 10
Re: Running a program from BAT file make the dos window stuck and open
« Reply #7 on: March 19, 2010, 02:15:04 PM »
Quote
lol anyways isn't IE a virus?

Maybe you mean that IE is the horse used by the Trojans.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Running a program from BAT file make the dos window stuck and open
« Reply #8 on: March 19, 2010, 10:58:10 PM »
It was just a joke, but one of the reasons you would want a batch file to continue running after executing something rather than waiting for the user.


Yeah, like that time I totally separated my user interface thread from my worker threads in order to create a consistent and responsive User Interface, I was so totally using techniques used for making viruses.

I am ashamed.
I was trying to dereference Null Pointers before it was cool.