Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

batch execution

May
31
0
I have 3 commands I would like to execute in a single alias or btm file.

Command 1: rename fileA fileB
Command 2: http://<my ISP website>
Command 3: rename fileB fileA

The trick is that I don't want command 3 to be executed until command 2 has completed - i.e., the browser has been closed. How can I do this?
 
In a BTM, something like
Code:
ren fileA fileB
start /wait path_to_browser_exe http://...
ren fileB fileA
But if the browser is already opened and the URL is opened via DDE, I don't think the "/wait" will work.
Or maybe ...
Code:
ren fileA fileB
http://...
delay 3
do while isapp path_to_browser_exe
  delay 1
enddo
ren fileB fileA
... or something like that.
 
In a BTM, something like
Code:
ren fileA fileB
start /wait path_to_browser_exe http://...
ren fileB fileA
But if the browser is already opened and the URL is opened via DDE, I don't think the "/wait" will work.
Or maybe ...
Code:
ren fileA fileB
http://...
delay 3
do while isapp path_to_browser_exe
  delay 1
enddo
ren fileB fileA
... or something like that.

The problem seems to be in the btm file, not the alias. Here's exactly what I'm trying to do (don't ask why the file rename; it works)

hosts is the alias that renames my hosts file to hosts.xxx if hosts.xxx doesn't exist, and the reverse if hosts.xxx exists.
https://myaccount.shaw.ca
hosts

as an alias, the first two commands work fine, but leave the hosts.xxx file in place of the regular hosts file.

If I separate the commands by putting them into a btm file, "hosts" is the only command that gets executed. Does the fact that "hosts" is an alias in a btm file fork the process out of the btm file, thus circumventing the rest of the btm file?

I just want to come up with a way to rename my hosts file, go to my ISP's website, and then when the browser closes, restore the original hosts file. As it stands now I have an alias that executes the first two commands, but I have to manually execute the hosts alias again to restore the original hosts file.
 
I don't think the name of the alias is a problem. I don't know what your alias does (and I'm not recommending mine) but this works here:
Code:
alias hosts if exist v:\hosts (ren v:\hosts hosts.xxx) else (ren v:\hosts.xxx hosts)
hosts
start /wait firefox http://google.com
echo FireFox has closed
hosts
unalias hosts
and it produces this output.
Code:
v:\> waittest.btm
V:\hosts -> V:\hosts.xxx
  1 file renamed
FireFox has closed
V:\hosts.xxx -> V:\hosts
  1 file renamed
 
The firefox.exe command just passes it's command line parameters to a browser master process an then immediately returns. So there is no chance to make your batch wait until you close the window or process. Not even start /wait will help.
 
That's correct. START /WAIT will not work if the browser is already running.

Perhaps you could loop while the window (the firefox tab) exists. Here, while replying to this thread with other firefox tabs open,
Code:
v:\> if iswindow "batch*Take Command*" echo yes
yes
 
The firefox.exe command just passes it's command line parameters to a browser master process an then immediately returns. So there is no chance to make your batch wait until you close the window or process. Not even start /wait will help.
You're wrong - it DOES work.
 
I don't think the name of the alias is a problem. I don't know what your alias does (and I'm not recommending mine) but this works here:
Code:
alias hosts if exist v:\hosts (ren v:\hosts hosts.xxx) else (ren v:\hosts.xxx hosts)
hosts
start /wait firefox http://google.com
echo FireFox has closed
hosts
unalias hosts
and it produces this output.
Code:
v:\> waittest.btm
V:\hosts -> V:\hosts.xxx
  1 file renamed
FireFox has closed
V:\hosts.xxx -> V:\hosts
  1 file renamed
Thank you! This worked perfectly.

However, my ISP has apparently fixed their login page which necessitated this workaround. No longer need to rename the hosts file.
 
You're wrong - it DOES work.
Am I? This is what the TCC help says:
Code:
Due to the way Windows handles URLs, you cannot wait for the browser to finish when you
enter an HTTP: URL at the prompt. 
In this situation, TCC always displays the next prompt immediately.
So who is wrong?
 
Am I? This is what the TCC help says:
Code:
Due to the way Windows handles URLs, you cannot wait for the browser to finish when you
enter an HTTP: URL at the prompt.
In this situation, TCC always displays the next prompt immediately.
So who is wrong?

I haven't tested the scenario myself; I can't speak to Mr. Hall's assertion. But the doc snippet you quote seems to be about entering a URL at the prompt -- not starting a URL with the START command.
 

Similar threads

Back
Top