Reputation: 13
I am programming using Delphi 2010 on a 32-bit Windows 7 PC.
The following code works when run on my PC as admin.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellApi;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ShellExecute(0,'open','command','/c ipconfig /all > testipco.txt','',0);
showmessage('Test IP Config file should be written');
end;
end.
The file TESTIPCO.TXT is output and contains the same results as typing ipconfig /all into a Command Prompt window.
When I compile the file and run it on a 64-bit Windows 8.1 PC as admin, the program appears to run OK, displaying the message (with no errors) but the file TESTIPCO.TXT is not produced.
Even running the exe on a Windows 8 machine with compatibility set to run as Windows 7 doesn't work.
I just cannot work out why this is the case. I'm hoping that one of you bright people may be able to steer me in the right direction.
Upvotes: 1
Views: 1616
Reputation: 29668
Have you tried cmd.exe
instead? Command
is a somewhat archaic reference.
Upvotes: 1