How to send a command to command.com

I want to control my PC via the Internet so I try to write a similar program. How can I send commands to command.com and how can I receive its answers ?

Comments

  • : I want to control my PC via the Internet so I try to write a similar program. How can I send commands to command.com and how can I receive its answers ?
    :
    I am not quite sure what you mean but if you start a command line program with the ">[FILENAME]" syntax you will write the info into a file. For instance the line "DCC32.EXE Project1.dpr >log.txt" will execute DCC32 and create screendump in log.txt.

    I don't know if this is helping in anyway but...
  • : : I want to control my PC via the Internet so I try to write a similar program. How can I send commands to command.com and how can I receive its answers ?
    : :
    : I am not quite sure what you mean but if you start a command line program with the ">[FILENAME]" syntax you will write the info into a file. For instance the line "DCC32.EXE Project1.dpr >log.txt" will execute DCC32 and create screendump in log.txt.
    :
    : I don't know if this is helping in anyway but...
    :
    I want to do something like this:

    ProgramName:='c:command.com';
    Write('Your command:');read(CmdLine);
    SwapVectors;
    Exec(ProgramName, CmdLine);
    SwapVectors;
    WriteLn('...back from Exec');
    if DosError <> 0 then{ Error? }
    WriteLn('Dos error #', DosError)
    else
    WriteLn('Exec successful. ',
    'Child process exit code = ',
    DosExitCode);
    end.

    But this is a Pascal source. I want to create almost the same program in Delphi. CmdLine will be received via the Internet instead of 7 lines my program will send me the answer of command.com . What do I use instead os SwapVectors and Exec ? How can I get the answer of command.com ?
  • : : : I want to control my PC via the Internet so I try to write a similar program. How can I send commands to command.com and how can I receive its answers ?
    : : :
    : : I am not quite sure what you mean but if you start a command line program with the ">[FILENAME]" syntax you will write the info into a file. For instance the line "DCC32.EXE Project1.dpr >log.txt" will execute DCC32 and create screendump in log.txt.
    : :
    : : I don't know if this is helping in anyway but...
    : :
    : I want to do something like this:
    :
    : ProgramName:='c:command.com';
    : Write('Your command:');read(CmdLine);
    : SwapVectors;
    : Exec(ProgramName, CmdLine);
    : SwapVectors;
    : WriteLn('...back from Exec');
    : if DosError <> 0 then{ Error? }
    : WriteLn('Dos error #', DosError)
    : else
    : WriteLn('Exec successful. ',
    : 'Child process exit code = ',
    : DosExitCode);
    : end.
    :
    : But this is a Pascal source. I want to create almost the same
    : program in Delphi. CmdLine will be received via the Internet instead
    : of 7 lines my program will send me the answer of command.com . What
    : do I use instead os SwapVectors and Exec ? How can I get the answer
    : of command.com ?
    :


    Replace

    SwapVectors;
    : Exec(ProgramName, CmdLine);
    : SwapVectors;

    with

    [size=3][/size][color=Blue]VAR
    ProcInfo: TProcessInformation;
    Startinfo: Tstartupinfo;

    Begin
    Startinfo.cb:=sizeof(startinfo);
    Fillchar(Startinfo,Sizeof(startinfo),0);
    CreateProcess(Nil,PAnsichar(ProgramName+' '+CmdLine,
    Nil, Nil[/color], false, 0, Nil, Nil, Startinfo, Procinfo);
    End;[/size]


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories