MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Run[] in background (NT)?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25524] Re: Run[] in background (NT)?
  • From: "P.J. Hinton" <paulh at wolfram.com>
  • Date: Thu, 5 Oct 2000 23:50:44 -0400 (EDT)
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at wolfram.com

Peter Meulbroek <meulbroek at wag.caltech.edu> writes:

> What about the old standbyes:
> 1)  create a shortcut to the app, and request that it startup as a
> minimized application (settable under the "properties" of the shortcut).  
> This works for Run["c:\\temp\\notepad.exe.lnk"] where notepad.exe.lnk is
> a shortcut to notepad, set as above.

Even in this situation, a console window appears.  If you have a fast
machine with a good graphics card, you might not see it because it is so
brief.

> 2) call the program from a vbscript, where you can specify the options
> of the call to the executable using the "WshShell.Run" method,
> specifying either a minimized or a hidden application.
>
> What's desired here is to instigate a call to "CreateProcess(Ex)" with
> ppropriate flags.  If the target application supports the nCmdShow flag
> of WinMain, you're golden.

The design of Run[] is intended to be more like the ANSI C function
system() rather than the Win32 function CreateProcess().  Under Windows,
system() passes its argument to the command interpreter (by default
C:\WINNT\system32\CMD.EXE under Windows NT/2000).  This results in the
console window popping up.

Using CreateProcess() in lieu of system() would make it impossible for the
user to take advantage of the interpreter's PATH environment variable, so
all commands would have to be entered with full paths, or the kernel's
working directory would have to be set to the location of the executable
before invoking the command.  You would also lose features of the command
interpreter like output redirection and the ability to run batch files.

For your situation, it wouldn't be too hard for you write a simple
MathLink program that that takes a list of arguments and passes the
arguments to CreateProcess().  To keep the MathLink program from placing
an icon on the taskbar, you could hard-code the nCmdShow parameter in the
WinMain() MathLink boilerplate to be SW_HIDE.

if( !MLInitializeIcon( hinstCurrent, SW_HIDE)) return 1;

-- 
P.J. Hinton
User Interface Programmer                         paulh at wolfram.com
Wolfram Research, Inc.




  • Prev by Date: Re: making a function linear
  • Next by Date: Re: Hold, HoldForm, ReleaseHold when Plotting multiple functions
  • Previous by thread: Re: Run[] in background (NT)?
  • Next by thread: Re: NDSolve : Stopping condition