diff --git a/Docs/src/compiler.but b/Docs/src/compiler.but index 89a0e4b0..29d7217c 100644 --- a/Docs/src/compiler.but +++ b/Docs/src/compiler.but @@ -40,6 +40,14 @@ This command will echo a message to the user compiling the script. This command will issue an error to the script compiler and will stop execution of the script. You can also add a message to this error. +\S1{execute} !execute + +\c command + +This command will execute 'command' using a call to CreateProcess(). Unlike \R{system}{!system}, it does not use the command line processor, so input/output redirection and commands like 'cd', 'dir' and 'type' can not be used. !execute also ignores the return value of the executed command. Currently, the only known advantage of !execute over \R{system}{!system} is that it does not give trouble when the current working directory is specified using UNC. + +On POSIX platforms, !execute will use system() just like \R{system}{!system}. + \S1{packhdr} !packhdr \c tempfile command diff --git a/Source/script.cpp b/Source/script.cpp index ae111164..cf16fdc4 100644 --- a/Source/script.cpp +++ b/Source/script.cpp @@ -2603,6 +2603,23 @@ int CEXEBuild::doCommand(int which_token, LineParser &line) SCRIPT_MSG("!system: returned %d\n",ret); } return PS_OK; + case TOK_P_EXECUTE: + { + char *exec=line.gettoken_str(1); +#ifdef _WIN32 + PROCESS_INFORMATION pi; + STARTUPINFO si={sizeof(STARTUPINFO),}; + if (CreateProcess(NULL,exec,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi)) + { + WaitForSingleObject(pi.hProcess,INFINITE); + CloseHandle(pi.hThread); + CloseHandle(pi.hProcess); + } +#else + system(exec); +#endif + SCRIPT_MSG("!execute: \"%s\"\n",exec); + } case TOK_P_ADDINCLUDEDIR: include_dirs.add(line.gettoken_str(1),0); return PS_OK; diff --git a/Source/tokens.cpp b/Source/tokens.cpp index b456c697..7e9cfa4c 100644 --- a/Source/tokens.cpp +++ b/Source/tokens.cpp @@ -216,6 +216,7 @@ static tokenType tokenlist[TOK__LAST] = {TOK_XPSTYLE, "XPStyle",1,0,"(on|off)",TP_GLOBAL}, {TOK_P_PACKEXEHEADER,"!packhdr",2,0,"temp_file_name command_line_to_compress_that_temp_file",TP_ALL}, {TOK_P_SYSTEMEXEC,"!system",1,2,"command [<|>|<>|=) retval]",TP_ALL}, +{TOK_P_EXECUTE,"!execute",1,0,"command",TP_ALL}, {TOK_P_ADDINCLUDEDIR,"!AddIncludeDir",1,0,"dir",TP_ALL}, {TOK_P_INCLUDE,"!include",1,0,"filename.nsi",TP_ALL}, {TOK_P_CD,"!cd",1,0,"absolute_or_relative_new_directory",TP_ALL}, diff --git a/Source/tokens.h b/Source/tokens.h index ad3147ae..29abb830 100644 --- a/Source/tokens.h +++ b/Source/tokens.h @@ -79,6 +79,7 @@ enum TOK_P_UNDEF, TOK_P_PACKEXEHEADER, TOK_P_SYSTEMEXEC, + TOK_P_EXECUTE, TOK_P_ADDINCLUDEDIR, TOK_P_INCLUDE, TOK_P_CD,