lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Thu, 15 Apr 2010 20:04:04 +0300, T T <t34www@googlemail.com> wrote:

2010/4/15 Enrico Colombini <erix@erix.it>:
...
This won't help, you will get to console windows: one for the start
command and another one (minimized) for "started" cmd.  There is no
way to get rid of the flashing window effect other than to pass the
appropriate flags to CreateProcess API (either DETACHED_PROCESS or
CREATE_NO_WINDOW in creation flags or SW_HIDE in startup info).

Anyway, the OP should use io.popen instead of os.execute to get the output.

Cheers,

Tomek

ntlua.start use that exactly, and if I am correct, I managed to do it months ago, but don't remember, how.
ntlua.start definition is:

static int ntlua_start(lua_State * L)
{
  char *command_line = get_string(L, "start", 1);
  int wait = luaL_optinteger(L, 2, 0);
  if (!utlStartProcess(command_line, wait))
    print_error(L, "start: can not start process.");
  return 0;
}

From process.c:

int utlStartProcess(char* command_line, int wait)
{
  WORD flags = NORMAL_PRIORITY_CLASS;
  STARTUPINFO si ;
PROCESS_INFORMATION* pi = (PROCESS_INFORMATION*) malloc(sizeof(PROCESS_INFORMATION));
  BOOL pr;

  ZeroMemory(&si , sizeof(STARTUPINFO)) ;
  si.cb = sizeof(STARTUPINFO) ;
	
pr=CreateProcess(NULL, command_line, NULL, NULL, TRUE, flags, NULL, NULL, &si, pi);

  if (wait && pr)
    WaitForSingleObject(pi->hProcess, (DWORD)(-1L)); // from dospawn.c
//    WaitForInputIdle(pi->hProcess, INFINITE);

	CloseHandle(pi->hThread);
	CloseHandle(pi->hProcess);
  free(pi);

  if (!pr)
	  return 0;

  return 1;
}

With these, is that possible?