Re: CreateProcess in a loop

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Gentlemen, I spotted the problem. Life of a programmer-creating hell
and then figuring out how the hell did I do that. :o) Inside this
loop, I was overwriting the actual command with junk that was being
issued in CreateProcess function.

STARTUPINFO si;
PROCESS_INFORMATION pi;
int i = 0;
while ( i < 6 )
{
ZeroMemory( &si, sizeof(si) );
si.cb = sizeof(si);
ZeroMemory( &pi, sizeof(pi) );

CreateProcess(function arguments);
WaitForSingleObject(some arguments);
// HERE I MESSED UP
// I changed the argument(command) being fed into CreateProcess to
some junk value. So when loop is executed
// again the command which suppose to be executed is lost.

CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
i++;
}

Since we are at this junction, I will explain what I am doing. My
goal with this code is to ping a network drive. If I am able to ping
it, then I derive at two logical conclusions, (1) I have a valid IP
assigned by DHCP and (2) I can run the code to map it. My real goal
is to detect if I have a valid IP address. Since currently I don't
know of any other method, I ping some server on network by the code
above. If anyone can suggest better alternatives, I am very
interested. Thanks for your comments/suggestions/questions. I
learned there are better ways of doing what I am doing.

.



Relevant Pages

  • RE: Error handling in a Do Loop
    ... When the loop hits a machine which produces an error description, ... On the very next loop, I get a ping reply, but I can't pull any information, ... > In your error handling code, use following line to clear the error info stored ... > - find out the line of code in script that is producing error messages ...
    (microsoft.public.windows.server.scripting)
  • Re: Problem using BackGroundWorker to ping multiple LAN hosts
    ... The "loop" is realy a timer object, but yes it's not the best option (I was ... 'This issues a ping in another thread. ... Dim Pinger As New Ping ... 'Calls the aupplied worker with the current value ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Local clock question with dialup connection
    ... && is a command operator which denotes an AND list. ... Ping the $TARGET 4 times throwing away all output. ... Break out of the loop ...
    (comp.protocols.time.ntp)
  • RE: Error handling in a Do Loop
    ... When loop is able to ping a computer and able to pull the information, ... > "Service tag" fields.. ... >> this will flush the ERR object. ...
    (microsoft.public.windows.server.scripting)