Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: ! / winexec minimized? (Windows XP)


From   Alan Riley <[email protected]>
To   [email protected]
Subject   Re: st: ! / winexec minimized? (Windows XP)
Date   Thu, 23 Mar 2006 15:54:21 -0600

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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index