On Windows XP, JMP 8.02, this works fine for me:
// clean up possible prior runs
SaveTextFile( "C:\temp\deleteme.bat",
"del C:\temp\deleteme.r"
);
Open( "C:\temp\deleteme.bat" );
If one tires of the flashing DOS window, JMP 8 adds the terriffic "LoadDll" command and you are off to the races.
http://support.sas.com/documentation/cdl/en/hostwin/61924/HTML/default/accdll.htm
http://msdn.microsoft.com/en-us/library/aa363851(VS.85).aspx
kernel32 = LoadDLL("Kernel32");
kernel32 << DeclareFunction("WinExec", Convention( STDCALL ), Alias "WinExec"),
Arg( AnsiString, "lpCmdLine" ),
Arg( Int32, "uCmdShow" ),
Returns( Int32 ) )
); // return value is greater than 31-> success
SW_HIDE = 0;
SW_MAXIMIZE = 3;
SW_MINIMIZE = 6;
SW_RESTORE = 9;
SW_SHOW = 5;
SW_SHOWDEFAULT = 10;
SW_SHOWMAXIMIZED = 3;
SW_SHOWMINIMIZED = 2;
SW_SHOWMINNOACTIVE = 7;
SW_SHOWNA = 8;
SW_SHOWNOACTIVATE = 4;
SW_SHOWNORMAL = 1;
// some examples
result = kernel32 << WinExec("Explorer C:\temp", 1); // 1=max, 6=minimized
show( result ); // returns 0 -> failure, nonzero -> success
// fire R GUI and bring to front
result = kernel32 << WinExec("Rterm", 1);
//
result = kernel32 << WinExec("Rgui", 0); // Rgui does not hide
// or, fire R term in background
result = kernel32 << WinExec("Rterm", 0);
// this works fine
result = kernel32 << WinExec("C:\temp\deleteme.bat", 0); // 1=show, 0=hide, result gt 31=success
Best regards,
-Matt