INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: running a bat file from MC12 in a command window  (Read 1480 times)

Osho

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1213
running a bat file from MC12 in a command window
« on: May 25, 2007, 11:45:47 am »

Hi,

I have created a custom command in Theater View to call a particular bat file from MC12. This works as expected and the bat file is called when I select that command in theater view. However, I don't see any window with the output of the .bat file (similar to cmd.exe window) when I run this bat file. Is there any way to see this window?

thanks,
Osho
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: running a bat file from MC12 in a command window
« Reply #1 on: May 25, 2007, 12:50:11 pm »

I have created a custom command in Theater View to call a particular bat file from MC12. This works as expected and the bat file is called when I select that command in theater view. However, I don't see any window with the output of the .bat file (similar to cmd.exe window) when I run this bat file. Is there any way to see this window?

It's probably because Theater View is set to be always on top, so the command window is there but is hidden.  Try unchecking Options --> Theater View --> Behavior --> Keep Focus.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Osho

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1213
Re: running a bat file from MC12 in a command window
« Reply #2 on: May 25, 2007, 05:39:52 pm »

It's probably because Theater View is set to be always on top, so the command window is there but is hidden.  Try unchecking Options --> Theater View --> Behavior --> Keep Focus.

Actually theater view does minimize itself when I execute this bat file. Anyways, it shouldn't matter because the first line of the .bat file is

C:\WINDOWS\SYSTEM32\MC12.EXE /Close

to terminate MC12 - which works correctly by the way!

thanks,
Osho
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: running a bat file from MC12 in a command window
« Reply #3 on: May 30, 2007, 10:32:11 am »

Aha!  That's why.  When you launch a BAT file from within MC, it is launched as a child process of MC's process.  When you kill MC, this child process becomes orphaned and windowless.  I'm guessing that they hid the CMD window when launched from within Theater View on purpose, because that's what most people would want.

A simple workaround is to launch the script using a WSH script instead to then launch your BAT file.  Check this thread: http://yabb.jriver.com/interact/index.php?topic=35576.msg243562#msg243562

and this one:
http://yabb.jriver.com/interact/index.php?topic=35953.msg244929#msg244929

You wouldn't want to re-write it in WSH, but just launch the BAT file from within a WSH "wrapper" script (though you could re-write it and then you could have a nice gui for your output with buttons and dialog boxes).  Then MC's logic that hides the command window wouldn't catch it (and you have more control over how the command window appears too).
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/

Osho

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 1213
Re: running a bat file from MC12 in a command window
« Reply #4 on: May 30, 2007, 10:56:44 am »

Thanks glynor but I found a much simpler solution via google search. Previously I was launching a foo.bat file. Now, I launch a bar.bat file which has only one line

start foo.bat

This seems to work - now I get the window.

Osho
Logged

glynor

  • MC Beta Team
  • Citizen of the Universe
  • *****
  • Posts: 19608
Re: running a bat file from MC12 in a command window
« Reply #5 on: May 30, 2007, 11:03:24 am »

Yep... That'd work too if all you want is a simple command window.
Logged
"Some cultures are defined by their relationship to cheese."

Visit me on the Interweb Thingie: http://glynor.com/
Pages: [1]   Go Up