"Bill Stewart" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Alex K. Angelopoulos wrote:
>
>> What API monitoring tool are you using? I'm curious because I've had
>> little luck with tracing the entire process for anything using Dependency
>> Walker's profiling.
>
> http://www.rohitab.com/apimonitor/
I like this tool; I just spent an hour playing with it, and I think it shows
us EXACTLY what is happening.
> Yes, I do think that a ShellExecute probably eventually results in a call
> to CreateProcess, but I'm not convinced that cmd.exe uses ShellExecute
> directly.
I am retracting my earlier suggestion that this is what is happening. Based
on items below, I don't see any reason for the call; it doesn't really save
much. It might happen, but it could just as easily be cmd.exe directly using
the registry expansion and then neglecting to try passing handles to the new
process.
> If I'm reading the API monitor's output correctly, it looks like cmd.exe
> first tries to call CreateProcess with the script file's name, which of
> course fails.
Yep. And if you look at the following extract showing two calls - the first
made calling the script directly, the second invoking it explicitly with
cscript - you can see that bInheritHandles is 0x0 (false) for the
creation-by-name case.
lpApplicationName: "C:\WINDOWS\System32\CScript.exe"
lpCommandLine: ""C:\WINDOWS\System32\CScript.exe" "c:\bin\scripts\rvs.vbs" "
bInheritHandles:0x0
lpApplicationName: "c:\windows\system32\cscript.exe"
lpCommandLine: "cscript rvs.vbs"
bInheritHandles:0x1
It looks like cmd.exe then determines the .js file
> association and calls CreateProcess again with cscript.exe as the
> executable name and the script file as its parameter (which looks correct,
> as far as it goes). I'm not sure where in this process that the input pipe
> gets broken, but I suspect that it's in the second call to CreateProcess.
Yeah - that bInheritHandles:0x0 proves you're right, that it does happen
during the second call. It also confirms that whatever the reason, cmd.exe
itself is explicitly saying to NOT inherit the handles.