@kas1e
From
AutoRun commodity:
static void execute_command(CONST_STRPTR command) {
struct Library *workbenchbase;
struct WorkbenchIFace *iworkbench;
BPTR path_list = ZERO;
BPTR input_file = ZERO;
BPTR output_file = ZERO;
int32 error = -1;
workbenchbase = IExec->OpenLibrary("workbench.library", 53);
iworkbench = (struct WorkbenchIFace *)IExec->GetInterface(workbenchbase, "main", 1, NULL);
if (iworkbench != NULL) {
iworkbench->WorkbenchControl(NULL,
WBCTRLA_DuplicateSearchPath, &path_list,
TAG_END);
}
input_file = IDOS->Open("NIL:", MODE_OLDFILE);
output_file = IDOS->Open("NIL:", MODE_OLDFILE);
if (input_file && output_file) {
error = IDOS->SystemTags(command,
NP_Name, "AutoRun Script",
NP_Path, path_list,
SYS_Asynch, TRUE,
SYS_Input, input_file,
SYS_Output, output_file,
SYS_Error, ZERO,
TAG_END);
}
if (error) {
IDOS->Close(input_file);
IDOS->Close(output_file);
}
if (error && iworkbench != NULL) {
iworkbench->WorkbenchControl(NULL,
WBCTRLA_FreeSearchPath, path_list,
TAG_END);
}
IExec->DropInterface((struct Interface *)iworkbench);
IExec->CloseLibrary(workbenchbase);
}