From: Kerem Gümrükcü on
Hi,

since i am not a big CreateProcess(...) user, this
problem bothers me a little: I wanted to start
"taskmgr.exe" from another application (running
elevated, means the creator runs elevated and
starts taskmgr.exe elevated too) but it fails with
2 (File not Found).

Thats what the call looks like:

BOOL _ret = CreateProcess(
NULL,
szExe,
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi);

....and it fails!

I checked my environment on the process
and it holds the PATH variables pointing to
the system directories where the taskmgr.exe
is in, but it fails to find them!

But when you read the MSDN doc for the
function on the "lpApplicationName" description,
then this is pretty unclear for me WHY this fails
with that parameters i pass to the function:

http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx

si and pi have been zero filled before called.
szExe holds "taskmgr.exe". What am i doing
wrong here? It perfectly work with a full path
but i dont want to compose a full path from
environment variables or API functions before
calling the function, because it should work
the way i called it,...at least i think it should.
I also dont want to use ShellExecute or WinExec,
because i need the hProcess of the STARTUPINFO.
The taskmgr.exe isnt really the Windows Taskmanager
its a replacement i want to comminicate with. It
uses the "Image File Execution Options" key in
the registry to route the call to my application.
I can perfectly start it with full path, or by using
command line shell, etc. there is no problem. I also
checked to run any application in the Windows
System32 directory,...with no success. It is the call
to CP(...) that fails and i think i am doing something
wrong here,...

The system is Windows Vista 32 bit, just for the
case you want to know where i want to execute
that,...

TIA,...

K.

--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------

From: David Craig on
The PATH is a feature of the shell and not CreateProcess(). You must
provide the full pathname to the executable you wish to execute. Since it
is running elevated, this is critical for security to keep a viral program
of the same name, but not in a protected directory from being executed.

"Kerem G�mr�kc�" <kareem114(a)hotmail.com> wrote in message
news:esZoUbUrKHA.3908(a)TK2MSFTNGP05.phx.gbl...
> Hi,
>
> since i am not a big CreateProcess(...) user, this
> problem bothers me a little: I wanted to start
> "taskmgr.exe" from another application (running
> elevated, means the creator runs elevated and
> starts taskmgr.exe elevated too) but it fails with
> 2 (File not Found).
>
> Thats what the call looks like:
>
> BOOL _ret = CreateProcess(
> NULL,
> szExe,
> NULL,
> NULL,
> FALSE,
> 0,
> NULL,
> NULL,
> &si,
> &pi);
>
> ...and it fails!
>
> I checked my environment on the process
> and it holds the PATH variables pointing to
> the system directories where the taskmgr.exe
> is in, but it fails to find them!
>
> But when you read the MSDN doc for the
> function on the "lpApplicationName" description,
> then this is pretty unclear for me WHY this fails
> with that parameters i pass to the function:
>
> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
>
> si and pi have been zero filled before called.
> szExe holds "taskmgr.exe". What am i doing
> wrong here? It perfectly work with a full path
> but i dont want to compose a full path from
> environment variables or API functions before
> calling the function, because it should work
> the way i called it,...at least i think it should.
> I also dont want to use ShellExecute or WinExec,
> because i need the hProcess of the STARTUPINFO.
> The taskmgr.exe isnt really the Windows Taskmanager
> its a replacement i want to comminicate with. It
> uses the "Image File Execution Options" key in
> the registry to route the call to my application.
> I can perfectly start it with full path, or by using
> command line shell, etc. there is no problem. I also
> checked to run any application in the Windows
> System32 directory,...with no success. It is the call
> to CP(...) that fails and i think i am doing something
> wrong here,...
>
> The system is Windows Vista 32 bit, just for the
> case you want to know where i want to execute
> that,...
>
> TIA,...
>
> K.
>
> --
> -----------------------
> Beste Gr�sse / Best regards / Votre bien devoue
> Kerem G�mr�kc�
> Latest Project: http://www.pro-it-education.de/software/deviceremover
> Latest Open-Source Projects: http://entwicklung.junetz.de
> -----------------------

From: Kerem Gümrükcü on
Hi David,

thanks for the response. Yes, i also finally
found out, that i have to provide a full
image path and i did it, there is really
no other way. But the MSDN documentation
is a little missleading here, since it seems
that there will be a search for the executable
on certain parameter inputs. I think they
should make this a little more clear,...

Regards

K.

--
-----------------------
Beste Gr�sse / Best regards / Votre bien devoue
Kerem G�mr�kc�
Latest Project: http://www.pro-it-education.de/software/deviceremover
Latest Open-Source Projects: http://entwicklung.junetz.de
-----------------------

"David Craig" <drivers(a)noemail.noemail> schrieb im Newsbeitrag
news:eGM4v6UrKHA.4752(a)TK2MSFTNGP04.phx.gbl...
> The PATH is a feature of the shell and not CreateProcess(). You must
> provide the full pathname to the executable you wish to execute. Since it
> is running elevated, this is critical for security to keep a viral program
> of the same name, but not in a protected directory from being executed.
>
> "Kerem G�mr�kc�" <kareem114(a)hotmail.com> wrote in message
> news:esZoUbUrKHA.3908(a)TK2MSFTNGP05.phx.gbl...
>> Hi,
>>
>> since i am not a big CreateProcess(...) user, this
>> problem bothers me a little: I wanted to start
>> "taskmgr.exe" from another application (running
>> elevated, means the creator runs elevated and
>> starts taskmgr.exe elevated too) but it fails with
>> 2 (File not Found).
>>
>> Thats what the call looks like:
>>
>> BOOL _ret = CreateProcess(
>> NULL,
>> szExe,
>> NULL,
>> NULL,
>> FALSE,
>> 0,
>> NULL,
>> NULL,
>> &si,
>> &pi);
>>
>> ...and it fails!
>>
>> I checked my environment on the process
>> and it holds the PATH variables pointing to
>> the system directories where the taskmgr.exe
>> is in, but it fails to find them!
>>
>> But when you read the MSDN doc for the
>> function on the "lpApplicationName" description,
>> then this is pretty unclear for me WHY this fails
>> with that parameters i pass to the function:
>>
>> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
>>
>> si and pi have been zero filled before called.
>> szExe holds "taskmgr.exe". What am i doing
>> wrong here? It perfectly work with a full path
>> but i dont want to compose a full path from
>> environment variables or API functions before
>> calling the function, because it should work
>> the way i called it,...at least i think it should.
>> I also dont want to use ShellExecute or WinExec,
>> because i need the hProcess of the STARTUPINFO.
>> The taskmgr.exe isnt really the Windows Taskmanager
>> its a replacement i want to comminicate with. It
>> uses the "Image File Execution Options" key in
>> the registry to route the call to my application.
>> I can perfectly start it with full path, or by using
>> command line shell, etc. there is no problem. I also
>> checked to run any application in the Windows
>> System32 directory,...with no success. It is the call
>> to CP(...) that fails and i think i am doing something
>> wrong here,...
>>
>> The system is Windows Vista 32 bit, just for the
>> case you want to know where i want to execute
>> that,...
>>
>> TIA,...
>>
>> K.
>>
>> --
>> -----------------------
>> Beste Gr�sse / Best regards / Votre bien devoue
>> Kerem G�mr�kc�
>> Latest Project: http://www.pro-it-education.de/software/deviceremover
>> Latest Open-Source Projects: http://entwicklung.junetz.de
>> -----------------------
>
From: Hector Santos on
Kerem G�mr�kc� wrote:

> Hi David,
>
> thanks for the response. Yes, i also finally
> found out, that i have to provide a full
> image path and i did it, there is really
> no other way. But the MSDN documentation
> is a little missleading here, since it seems
> that there will be a search for the executable
> on certain parameter inputs. I think they
> should make this a little more clear,...

Yes, I always thought CreateProcess() description misleading for as
long as I used it for many years. Depending on what we needed it for,
properly exiting a process or batch file and/or getting the exit code
was historically tricky under Windows history, especially for batch files.

Anyway, one way to resolve running a process that is under the PATH or
run a batch file is to use the COMSPEC like so:

Method 1:

char cmd[MAX_PATH] = {0};
strcpy(cmd,getenv("comspec"));
strcat(cmd," /c ");
strcat(cmd,"taskmgr.exe");

CreateProcess(NULL, (char *)cmd, ....

Method 2:

char szCmd[MAX_PATH] = {0};
strcpy(szCmd,"/c ");
strcat(szCmd,"taskmgr.exe");

CreateProcess(getenv("comspec"),(char *)szCmd, ....

That will allow the comspec to find it on the path. Using the comspec
allows you to work with PURE DOS (command.com) or NT-based command
line processor (CMD.EXE). "/C" says wait until finished. Open a
console/dos box and type CMD /? to see all the options.

Basically, you can only pass arguments with the 2nd parameter
(lpCommandLine). If the 1st parameter (lpApplicationName,)is NULL,
then you need to provide the process/batch file in the 2nd parameter
followed with a space plus arguments. Otherwise pass the process name
in the 1st, and the arguments only in the 2nd.

--
HLS
From: Pavel A. on
No, of course PATH is not a "shell feature".
On Vista your CreateProcess() fails probably because the app fails to find
its MUI resources.
The easiest and safest is just to use the full path (expand
%SYSTEMROOT%....)

Regards,
--pa


"Kerem G�mr�kc�" <kareem114(a)hotmail.com> wrote in message
news:uq7dLMVrKHA.1796(a)TK2MSFTNGP02.phx.gbl...
> Hi David,
>
> thanks for the response. Yes, i also finally
> found out, that i have to provide a full
> image path and i did it, there is really
> no other way. But the MSDN documentation
> is a little missleading here, since it seems
> that there will be a search for the executable
> on certain parameter inputs. I think they
> should make this a little more clear,...
>
> Regards
>
> K.
>
> --
> -----------------------
> Beste Gr�sse / Best regards / Votre bien devoue
> Kerem G�mr�kc�
> Latest Project: http://www.pro-it-education.de/software/deviceremover
> Latest Open-Source Projects: http://entwicklung.junetz.de
> -----------------------
>
> "David Craig" <drivers(a)noemail.noemail> schrieb im Newsbeitrag
> news:eGM4v6UrKHA.4752(a)TK2MSFTNGP04.phx.gbl...
>> The PATH is a feature of the shell and not CreateProcess(). You must
>> provide the full pathname to the executable you wish to execute. Since
>> it is running elevated, this is critical for security to keep a viral
>> program of the same name, but not in a protected directory from being
>> executed.
>>
>> "Kerem G�mr�kc�" <kareem114(a)hotmail.com> wrote in message
>> news:esZoUbUrKHA.3908(a)TK2MSFTNGP05.phx.gbl...
>>> Hi,
>>>
>>> since i am not a big CreateProcess(...) user, this
>>> problem bothers me a little: I wanted to start
>>> "taskmgr.exe" from another application (running
>>> elevated, means the creator runs elevated and
>>> starts taskmgr.exe elevated too) but it fails with
>>> 2 (File not Found).
>>>
>>> Thats what the call looks like:
>>>
>>> BOOL _ret = CreateProcess(
>>> NULL,
>>> szExe,
>>> NULL,
>>> NULL,
>>> FALSE,
>>> 0,
>>> NULL,
>>> NULL,
>>> &si,
>>> &pi);
>>>
>>> ...and it fails!
>>>
>>> I checked my environment on the process
>>> and it holds the PATH variables pointing to
>>> the system directories where the taskmgr.exe
>>> is in, but it fails to find them!
>>>
>>> But when you read the MSDN doc for the
>>> function on the "lpApplicationName" description,
>>> then this is pretty unclear for me WHY this fails
>>> with that parameters i pass to the function:
>>>
>>> http://msdn.microsoft.com/en-us/library/ms682425%28VS.85%29.aspx
>>>
>>> si and pi have been zero filled before called.
>>> szExe holds "taskmgr.exe". What am i doing
>>> wrong here? It perfectly work with a full path
>>> but i dont want to compose a full path from
>>> environment variables or API functions before
>>> calling the function, because it should work
>>> the way i called it,...at least i think it should.
>>> I also dont want to use ShellExecute or WinExec,
>>> because i need the hProcess of the STARTUPINFO.
>>> The taskmgr.exe isnt really the Windows Taskmanager
>>> its a replacement i want to comminicate with. It
>>> uses the "Image File Execution Options" key in
>>> the registry to route the call to my application.
>>> I can perfectly start it with full path, or by using
>>> command line shell, etc. there is no problem. I also
>>> checked to run any application in the Windows
>>> System32 directory,...with no success. It is the call
>>> to CP(...) that fails and i think i am doing something
>>> wrong here,...
>>>
>>> The system is Windows Vista 32 bit, just for the
>>> case you want to know where i want to execute
>>> that,...
>>>
>>> TIA,...
>>>
>>> K.
>>>
>>> --
>>> -----------------------
>>> Beste Gr�sse / Best regards / Votre bien devoue
>>> Kerem G�mr�kc�
>>> Latest Project: http://www.pro-it-education.de/software/deviceremover
>>> Latest Open-Source Projects: http://entwicklung.junetz.de
>>> -----------------------
>>
 |  Next  |  Last
Pages: 1 2
Prev: Icons in Menus
Next: Off to MVP Summit!