ShellExecute & ipconfig.exe

I want to run ipconfig within my program and write the data to a file.
I tried the following codes but none of them worked.

ShellExecute(0, PChar('open'), PChar('ipconfig.exe'), PChar('/all > C:\output.tmp'), nil, SW_HIDE);

ShellExecute(0, PChar('open'), PChar('ipconfig.exe > c:\output.tmp'), PChar('/all'), nil, SW_HIDE);

If I run those commands in a DOS-Box they both work!
What am I doing wrong ??

Thanks in advance,
Tulip
TulipAsked:
Who is Participating?
 
ITugayConnect With a Mentor Commented:
try this:
ShellExecute(0,'open','command','/c ipconfig /all > c:\output.tmp','',0);

Cheers,
Igor.
0
 
intheCommented:
hi tulip,
try it using winexec instead.
there was similar question the other day when shellexecute wouldnt work but winexec did.
0
 
ITugayCommented:
try this:
ShellExecute(0,'open','command','/c ipconfig /all > c:\output.tmp','',0);

Cheers,
Igor.
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
klasseCommented:
I'm a bit confused everyone concerned... Does the /all flag really work? On my Win98 machine it doesn't, however the /batch filename command work fine..
And therefor the commandline parametr I'd use is similar to all above..
ShellExecute(Application.handle, 'open', 'ipconfig.exe', '/batch C:\output.tmp', nil, SW_Hide); - This works just fine, though I'm still puzzled regarding that /all flag...

good Luck
/©h®is
0
 
TulipAuthor Commented:
klasse, I'm using NT4 SP5
Maybe, that's the difference.
0
 
TulipAuthor Commented:
WinExec doesn't work, but Igor's example does !
This is strange.
Anyway, thanks to all of you.
0
 
ITugayCommented:
Tulip,
I have NT too, there no "/batch" option in our case;).
I can explain why you sample didn't work, if you need.

Best regards,
Igor.
0
 
TulipAuthor Commented:
I'm listening ...
0
 
TulipAuthor Commented:
I'm listening ...
0
 
ITugayCommented:
Tulip,

The problem is that "> redirection" is option for command.com, not for executable module. It come from MS-DOS. If you run your applicaton with command.com and look at parameters, you even don't see "> ...". And, of course, IPCONFIG can't process this option. I mean that redirection of output is command.com's deals.

The option "/C" is command.com option. It mean "carries out application, then stop".

My expression is analog of
C:> command /C ipconfig /all > C:\output.tmp

Best regards,
Igor.
0
 
TulipAuthor Commented:
Thanks, Igor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.