Batch Program

kirsch59

Member
I'm running WebSpeed (10.1C) on a Windows 2003 server. I'm trying to run a batch job in the background from a cgi program. The batch job works when I run it from a command prompt; however, from the cgi program I believe the batch job is not running in the background. Does anyone have sample code for subimitting a batch program in the background (Windows)? I'm using the following code. I wonder if I need to set a Window's security setting.

RUN createProcess (INPUT batch).

{windowsapi.i} /* Procedures for Windows API to run process in backgroud */

The contents of windowsapi.i is
PROCEDURE createProcess:
/*------------------------------------------------------------------------
Purpose: Create and run a process in background on Windows OS ------------------------------------------------------------------------*/
DEF INPUT PARAM ipBatchFilename AS CHAR NO-UNDO.
DEF VAR lpStartupInfo AS MEMPTR NO-UNDO.
DEF VAR lpProcessInformation AS MEMPTR NO-UNDO.
DEF VAR bResult AS INT NO-UNDO.
DEF VAR hThread AS INT NO-UNDO.
SET-SIZE(lpStartupInfo) = 68.
PUT-LONG(lpStartupInfo,1) = 68.
PUT-LONG(lpStartupInfo,45) = 1.
PUT-SHORT(lpStartupInfo,49) = 0.
SET-SIZE(lpProcessInformation) = 16.
RUN CreateProcessA (
INPUT 0,
INPUT ipBatchFilename,
INPUT 0,
INPUT 0,
INPUT 0,
INPUT 0,
INPUT 0,
INPUT 0,
INPUT GET-POINTER-VALUE(lpStartupInfo),
INPUT GET-POINTER-VALUE(lpProcessInformation),
OUTPUT bResult
).
hThread = GET-LONG(lpProcessInformation,5).
RUN CloseHandle (
INPUT hThread
).
SET-SIZE(lpStartupInfo) = 0.
SET-SIZE(lpProcessInformation) = 0.
END PROCEDURE. /* createProcess */

PROCEDURE CreateProcessA EXTERNAL "kernel32":
/*------------------------------------------------------------------------
Purpose: windows API call to create and run a process in background
on Windows OS
------------------------------------------------------------------------*/
DEF INPUT PARAM lpApplicationName AS LONG.
DEF INPUT PARAM lpCommandline AS CHAR.
DEF INPUT PARAM lpProcessAttributes AS LONG.
DEF INPUT PARAM lpThreadAttributes AS LONG.
DEF INPUT PARAM bInheritHandles AS LONG.
DEF INPUT PARAM dCreationFlags AS LONG.
DEF INPUT PARAM lpEnvironment AS LONG.
DEF INPUT PARAM lpCurrentDirectory AS LONG.
DEF INPUT PARAM lpStartupInfo AS LONG.
DEF INPUT PARAM lpProcessInformation AS LONG.
DEF return PARAM bResult AS LONG.
END PROCEDURE. /* CreateProcessA */
PROCEDURE CloseHandle EXTERNAL "kernel32":
/*------------------------------------------------------------------------
Purpose: windows API call to clean up a background process on Windows OS
------------------------------------------------------------------------*/
DEF INPUT PARAM hObject AS LONG.
END PROCEDURE. /* CloseHandle */

Thanks
Mark
 
Back
Top