Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ShellExecute & ipconfig.exe

Posted on 2000-03-09
11
Medium Priority
?
1,633 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:Tulip
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
11 Comments
 
LVL 17

Expert Comment

by:inthe
ID: 2600704
hi tulip,
try it using winexec instead.
there was similar question the other day when shellexecute wouldnt work but winexec did.
0
 
LVL 9

Accepted Solution

by:
ITugay earned 200 total points
ID: 2600732
try this:
ShellExecute(0,'open','command','/c ipconfig /all > c:\output.tmp','',0);

Cheers,
Igor.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2600744
try this:
ShellExecute(0,'open','command','/c ipconfig /all > c:\output.tmp','',0);

Cheers,
Igor.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:klasse
ID: 2600952
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
 

Author Comment

by:Tulip
ID: 2600989
klasse, I'm using NT4 SP5
Maybe, that's the difference.
0
 

Author Comment

by:Tulip
ID: 2601071
WinExec doesn't work, but Igor's example does !
This is strange.
Anyway, thanks to all of you.
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2601083
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
 

Author Comment

by:Tulip
ID: 2601098
I'm listening ...
0
 

Author Comment

by:Tulip
ID: 2601113
I'm listening ...
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2601268
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
 

Author Comment

by:Tulip
ID: 2601510
Thanks, Igor
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question