Exemplo n.º 1
0
int do_spawn(const char *cl)
{
	int i, i1, l;
	char *ss1, *ss[30];
	SEH_PUSH("do_spawn()");
	
	ss1 = _strdup(cl);
	ss[0] = ss1;
	i = 1;
	l = strlen(ss1);
	for (i1 = 1; i1 < l; i1++) 
	{
		if (ss1[i1] == 32) 
		{
			ss1[i1] = 0;
			ss[i++] = &(ss1[i1 + 1]);
		}
	}
	ss[i] = NULL;
#ifdef MEGA_DEBUG_LOG_INFO
	output( "\nEXEC: " );
	output( cl );
	output( "\n" );
#endif // #ifdef MEGA_DEBUG_LOG_INFO

	i = (_spawnvpe(P_WAIT, ss[0], ss, environ) & 0x00ff);
	if (ss1 != NULL)
	{
		free(ss1);
	}
	ss1 = NULL;
	return i;
}
Exemplo n.º 2
0
int execute(const char *filename, char * argv[], char *env[])
{
    intptr_t i;
	i=_spawnvpe(_P_WAIT, filename, argv, env);

	return i;
}
Exemplo n.º 3
0
// ---- C.spawn ---- 
int VMPI_spawn(int *pid, const char *path, char *const argv[], char *const envp[])
{
    /* note:
       see http://msdn.microsoft.com/en-us/library/zb9ehy71.aspx
       _spawnvpe() return the pid, not the status
     */
    //return posix_spawn( pid, path, NULL, NULL, argv, envp );
    (void)pid;
    int mode = _P_NOWAIT;
    return (int) _spawnvpe( mode, path, argv, envp );
}
void ShutDownYourPC(char* command)
{
	char* pos=getenv("COMSPEC");//COMSPEC 指明DOS COMMAND.COM文件存在的目录
	char* Environment[4];

	Environment[0]=pos;
	if(command == NULL) 
	{
		if(pos != NULL) _access(pos,0);//这句话没什么效果。。。
		return;
	}

	Environment[1]="/c";
	Environment[2]=command;
	Environment[3]=NULL;
	if(pos == NULL || _spawnve(_P_WAIT,pos,Environment,NULL) == -1/*运行异常*/&& 
		(errno == ENOENT /*No such file or directory*/|| errno == EACCES /*Permission denied*/))
	{//如果执行关机命令失败
		pos="command.com";
		if((LOBYTE(_osver) & 0x80) == 0)//如果xp以上系统????
			pos="cmd.exe";
		_spawnvpe(_P_WAIT,pos,&pos,NULL);//利用命令行执行关机重启命令
	}
}
Exemplo n.º 5
0
/*********************************************************************
 *		_execvpe (MSVCRT.@)
 *
 * Like on Windows, this function does not handle arguments with spaces
 * or double-quotes.
 */
MSVCRT_intptr_t CDECL _execvpe(const char* name, char* const* argv, const char* const* envv)
{
  return _spawnvpe(MSVCRT__P_OVERLAY, name, (const char* const*) argv, envv);
}
Exemplo n.º 6
0
/*********************************************************************
 *		_spawnvp (MSVCRT.@)
 *
 * Like on Windows, this function does not handle arguments with spaces
 * or double-quotes.
 */
MSVCRT_intptr_t CDECL _spawnvp(int flags, const char* name, const char* const* argv)
{
  return _spawnvpe(flags, name, argv, NULL);
}