Computer Hope

Microsoft => Microsoft Windows => Windows Vista and 7 => Topic started by: joker197cinque on March 18, 2010, 07:14:48 AM

Title: Running a program from BAT file make the dos window stuck and open
Post by: joker197cinque on March 18, 2010, 07:14:48 AM
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]
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Geek-9pm 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.
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Salmon Trout 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"
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: BC_Programmer 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.
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Azzaboi 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...
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Geek-9pm 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?
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Azzaboi 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?
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: Geek-9pm 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.
Title: Re: Running a program from BAT file make the dos window stuck and open
Post by: BC_Programmer 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.