turbopack / doscommand Goto Github PK
View Code? Open in Web Editor NEWThis component let you execute a dos program (exe, com or batch file) and catch the ouput in order to put it in a memo or in a listbox.
License: Other
This component let you execute a dos program (exe, com or batch file) and catch the ouput in order to put it in a memo or in a listbox.
License: Other
Trying to use this tool to interact with nodeJS from Delphi, but failing due to
"ECreateProcessError with message 'Error creating Process: npx hardhat test - (The system cannot find the file specified)'. Process DemoListWindowsDir.exe (17516)"
Starting CMD on Win10 directly and running the command from any folder in the system works just fine and I made sure the nodeJS install folder is added to the PATH in the system, but it feels like the DOSCommand instance does not get the same permissions or scope to access the windows path.
I've tried various edits in the supplied object properties "Environment" thinking it works as key-value pairs, like so
PATH="C:\Program Files\nodejs"
but all that achieves is crashing bds.exe with an access violation.
This comment in the code seems to hint at the format, despite typos, but that seems to only separate the variables in case there are multiple
"environmentstrings are devided bei #0"
How could this be helped?
hello,
please i need your help,
is there a way to send virtual keyboard strokes to the console ?
i need to send a PAUSE key
the SendLine procedure sends only string ..
is there a way ?? please
When trying to retrieve the output of the program using OutputLines, the stringlist contains duplicated lines. Sometimes a line may be duplicated only once.... other times in may be duplicated dozens of times.
How to fix:
See attached files.
TDOSCommand can only be started once. If I want wo start it a second one then I get the Message "Doscommand is still running". This also happens in the Demo project!
I looks like the threads are not terminated correctly. The function TDOSCommand.Stop causes the program hang.
I was getting an intermittent thread exception on termination. I fixed by moving:
FThread.FreeOnTerminate := False;
from TDosCommand.Stop and placed it after the thread is created in TDosCommand.Execute.
This seems to fix the issues I've been having. Can someone please confirm.
It doesn't work when I use the absolute directory in the Win 64 Plathform,such as "DosCommand1.CurrentDir := "E:\TEST\test.exe"",when I use the command "doscomand1.execute",it will catch an error which shows [the system cannot find the file specified]。but if I put the third exe program in the same directory of my delphi exe program,use the following statement,"DosCommand1.CurrentDir := GetCurrentDir;",it works。
In the win32 Platform,it's fine!
I want to Thank you so much !
It's a very unfortunate, as DOSCommand looks much sleeker than handling stuff with ShellExecute, which is too bare-bones and not explained well either. But I've not the foggiest on how to properly run DOSCommand.
For example, there is no explanation on:
My current issue, is that DOSCommand spawns a huge number of threads, faster than they exit. After 20 seconds of execution, my system is flooded with threads, and Delphi won't make any more. Even though I make sure to wait for execution to finish with the following statements:
while dosToRun.EndStatus = TEndStatus.esStill_Active do
sleep(1);
There needs to be actual documentation. Two lines that don't do anything, and throw errors because more code needs to be added to the .pas file before they can actually function, is not enough to work with at all.
I'm happy to provide my current command line project, if that would help. It only has around 120 lines of code excluding whitespace.
I was getting weird output in Delphi XE 4. All outputs are in chinese character.
DosCommand1.CommandLine := 'cmd /c dir C:'
the ouput is like this:
嘠汯浵湩搠楲敶䌠栠獡渠慬敢嘠汯浵敓楲污丠浵敢獩㠠䌰ⴰ㘴䘵䐠物捥潴祲漠㩃൜ഊ《⼵㤲㈯‶〠㨶㈴倠⁍†㰠䥄㹒†††††敄灬楨㜠挠浯潰敮瑮㔰㈯⼹〲㘱†㜰㌺‰䵐††䐼剉‾††††映浦数൧《⼷〱㈯‵〠㨶㐰倠⁍†㰠䥄㹒†††††敐晲潌獧㔰㈯⼹〲㘱†㈰㔺‶䵐††䐼剉‾††††倠潲牧浡䘠汩獥㔰㈯⼹〲㘱†㌰㈺‹䵐††䐼剉‾††††倠潲牧浡䘠汩獥⠠㡸⤶㔰㈯⼹〲㘱†㌺‸䵐††䐼剉‾††††唠敳獲㔰㈯⼹〲㘱†㐺‷䵐††䐼剉‾††††圠湩潤獷†††††††〠䘠汩⡥⥳†††††††‰祢整൳ †††††††‷楄⡲⥳†㜷㔬㠰〬㠳㘬㘵戠瑹獥映敲
The comments located near the properties and methods of TDosCommand don't match. I guess this happened while reordering the class interface with a tool like ModelMaker Code Explorer with "Associate Comments" set to "Associate all preceding comments with entities" (the default). The original sources seem to have comments located in the line following the properties and methods.
First a deep thanks for this component.
I'm a newbie here on Git, so pleas excuse me if this is inappropriate or wrong, but
I'm asking for adding some coding examples to use this component.
I'm using Delphi 10.3 Rio Community, and it has been installed flawlessly with the IDE tool.
I'd like to find a coding example to use all the features of the component, that seems very powerful.
Please point me to some coding example or integrate some examples in the sources.
Thank you very much
Sergio
in the demo show how to save the output in a memo, but
How do I save to a text file?
Your component is awesome! But there is something I don't understand about synchronization.
I create a batch file inside my app and I redirect the output lines of the commands to a TListView. Everything works, excpet that lines appear in the TListView not synchronized! I mean: my code flow goes on after I run DOSCommand.Execute, but it doesn't wait for it to finish, so when other lines get added to the list (I use it as a log), at a certain point the output lines of the batch appear in the list view.
I just want that the batch file is executed and only AFTER my code flow continue! If I wouldn't be using your component I will run the batch with the API to wait for the process to finish.
Then, joined to this issues, there is this one: I found that if I execute with DOSCommand a command, then, again, it doesn't wait to it to be finished, so the next Execute rais an error saying that the previous command is still running! And if I add something like
while Self.DosCommand.IsRunning do Sleep(1000);
the process hangs forever, becuase IsRunning is always True, forever! I expected that after the command terminates IsRunning would return False.
What am I missing?
Ich erhalte die immer die Fehlermeldung "Thread-Fehler: Das Handele ist ungültig (6)" wenn das mit execute aufgerufene Programm noch läuft wenn z.B. TDosCommand.Stop aufgerufen wird bzw. das Hauptprogramm beendet wird.
Getestet habe ich das unter Windows 10 x64, starten von gohstscript gswin9.21c.exe ohne -dBATCH oder Notepad++.exe
There is some empty lines in the middle when you run the following command. How to solve it.thank you
wmic memorychip
The assert errors (in DosCommand.pas) appear on user's face. They should be removed.
I made a sample console application which writes some console messages with WriteLn and with LoggerPro library
There is missing lines on output strings when ecexuted with DosCommand.
Output is ;
Console message 1
Console message 2
Console message 3
Console message 4
Console message 5
Console message 6
Console message 7
Console message 8
Console message 9
Console message 10
Console message 11
Console message 12
Console message 13
Console message 14
Console message 15
Console message 16
Console message 17
Console message 18
Console message 19
Console message 20
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 1 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 1 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 1 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 1 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 2 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 2 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 2 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 2 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 3 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 3 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 3 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 3 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 4 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 4 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 4 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 4 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 5 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 5 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 5 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 5 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 6 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 6 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 6 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 6 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 7 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 7 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 7 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 7 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 8 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 8 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 8 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 8 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 9 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 9 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 9 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 9 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][DEBUG ] Log message 10 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][INFO ] Log message 10 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][WARNING ] Log message 10 [Test]
2022-03-15 12:24:07:843 [TID 17056 ][ERROR ] Log message 10 [Test]
But OnNewLine event getting only,
Console message 1
Console message 2
Console message 3
Console message 4
Console message 5
Console message 6
Console message 7
Console message 8
Console message 9
Console message 10
2022-03-15 12:33:47:813 [TID 29524 ][DEBUG ] Log message 1 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][INFO ] Log message 1 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][WARNING ] Log message 1 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][ERROR ] Log message 1 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][DEBUG ] Log message 2 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][INFO ] Log message 2 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][WARNING ] Log message 2 [Test]
2022-03-15 12:33:47:813 [TID 29524 ][ERROR ] Log mes20 [Test]
Test projects is on the attachment.
Console App code ;
program DosCommandTest;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
LoggerPro,
LoggerPro.ConsoleAppender;
const c_defTAG = 'Test';
var
Log: ILogWriter;
begin
try
for var i := 1 to 10 do
Writeln('Console message ' + i.ToString);
Log := BuildLogWriter([TLoggerProConsoleAppender.Create]);
for var i := 1 to 10 do
begin
Log.Debug('Log message ' + i.ToString(), c_defTAG);
Log.Info('Log message ' + i.ToString(), c_defTAG);
Log.Warn('Log message ' + i.ToString(), c_defTAG);
Log.Error('Log message ' + i.ToString(), c_defTAG);
end;
Sleep(20000);
{ TODO -oUser -cConsole Main : Insert code here }
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Test App code;
unit ConsoleLogMain;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DosCommand, Vcl.StdCtrls;
type
TForm8 = class(TForm)
Memo1: TMemo;
Button1: TButton;
DosCommand1: TDosCommand;
procedure Button1Click(Sender: TObject);
procedure DosCommand1NewLine(ASender: TObject; const ANewLine: string;
AOutputType: TOutputType);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form8: TForm8;
implementation
{$R *.dfm}
procedure TForm8.Button1Click(Sender: TObject);
begin
DosCommand1.CommandLine := ExtractFilePath(Application.ExeName) + 'DoscommandTest.exe';
DosCommand1.CurrentDir := ExtractFilePath(Application.ExeName);
Memo1.Lines.Clear;
DosCommand1.Execute;
end;
procedure TForm8.DosCommand1NewLine(ASender: TObject; const ANewLine: string;
AOutputType: TOutputType);
begin
if AOutputType = otEntireLine then
begin
Memo1.Lines.Add(ANewLine);
end;
end;
end.
Under Win10X64 administrator privileges, TDosCommand seems unable to work.
Command:
D:\Qampp\yt-dlp.exe --format 137,140 -continue --output "down.mkv" "https://www.youtube.com/watch?v=fsG1XaZEa78"
Please refer to the return value of the system cmd form,
dos command output String, sometimes one more line.
For example:
ffprobe.exe -hide_banner -v quiet -show_streams -print_format json 01.mp4
retrun json, one more line "}"
when CommandLine is a cmd file, DOSCommand.Stop is not effect.
when i open the : DOSCommandDR on Delphi XE7 and compile it,, it give me Warning
[dcc32 Warning] DosCommand.pas(1): W1025 Unsupported language feature: 'class constructor'
so,, how can i install the DosCommand Component on delphi xe7..??
thx
Hello,
I tried the installation from GetIt and Github in Alexandria 11.2. Registration of the component fails.
I am using delphi in a Windows on Arm environment. Any help would be appreciated.
Kind regards
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.