| |
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: ! / winexec minimized? (Windows XP)
Thanks Alan--this gives me exactly what I needed.
I had considered the "run winexec and watch for a 'blocking' file"
approach, but that seemed messy and prone to problems, if, for
example, the program being called failed and therefore didn't erase
the blocking file.
But AutoIt scripts can be compiled, and AutoIt can make calls to DOS
commands that are done in minimized or hidden windows, so it is easy
enough to create an executable to do what I want, then adjust Stata's
S_SHELL to call it.
Nifty!
--Nick Winter
At 04:54 PM 3/23/2006, you wrote:
Nick Winter asked about invoking a shell from Stata without a visible
window for the shell. Dimiriy Masterov replied that this may
be possible using AutoIt. Nick, however, still has the problem of
an initial visible command window:
> Yes, I use AutoIt, and yes, it can invoke things minimized. But I
> can't invoke AutoIt from Stata without a maximized window . . .
Nick should read the technical note near the top of page 436 of the
Stata 9 Data Management Reference Manual. It says
Although we do not recommend it, Stata for Windows users can change
the shell that Stata calls. By default, Stata for Windows calls
the program command.com for a DOS shell when running under Windows
ME or 98 and calls cmd.exe when running under Windows XP, 2000, or NT.
To change the shell that Stata calls, set the global macro $S_SHELL to
contain the name of the executable program you want Stata to use for
the shell.
I do not have experience with AutoIt, and this is a try-at-your-own-risk
solution, but perhaps Nick can achieve what he wants by setting $S_SHELL
temporarily to contain the name of the AutoIt executable (possibly
including the full path to allow Windows to find it).
Stata's -winexec- command can also kick off any other application.
However, -winexec- will not wait for that application to complete
before Stata continues execution. If Nick needs to go this route
and needs a way to block Stata from continuing execution until his
external program is done, he could code something like
...
<command in Stata (perhaps -file-) to create some placeholder file.
For this example, let's call it C:\TEMP\blockit.txt.>
winexec <whatever>
capture confirm file C:\TEMP\blockit.txt
while _rc == 0 {
sleep 1000
capture confirm file C:\TEMP\blockit.txt
}
...
Nick would create a 'blocking' file. He would then launch his
external program with -winexec- under the assumption that this
external program will remove the blocking file as soon as it is
complete. -winexec- allows Stata to continue execution immediately,
so a loop is needed to check for the existence of the blocking file.
As long as it exists, Stata will pause for 1 second, then check again
for the existence of the file. As soon as Nick's external program
removes the blocking file, Stata will be able to continue execution.
Alan
([email protected])
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/
________________________________________________________
Nicholas J. G. Winter 607.255.8819 t
Assistant Professor 607.255.4530 f
Department of Government [email protected] e
Cornell University falcon.arts.cornell.edu/nw53 w
308 White Hall
Ithaca, NY 14853-4601
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/