Autor Beitrag
holger
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 46

W2K pro, XP pro
Delphi 6, Delphi 2007
BeitragVerfasst: Mo 03.10.05 12:36 
Hallo Leute,

Mit dem Befehl

ausblenden Delphi-Quelltext
1:
ShellExecute(0,nil, PChar('tracert'),Pchar('192.168.80.25'),Pchar(''),SW_NORMAL)					


öffne ich ein DOS-Fenster. Hier im Beispiel mit "Tracert 192.168.80.25"

Wie kann ich verhindern, daß sich das DOS-Fenster sofort nach abarbeiten des Befehles "Tracert 192.168.80.25" wieder schließt?

Ich könnte auch eine Batchdatei mit dem Inhalt
ausblenden Quelltext
1:
2:
tracert %1
 pause

starten.

Aber ich kann das doch bestimmt auch mit dem ShellExecute hin bekommen.
Wie geht das?

Vielen Dank im Voraus
Holger

Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt.
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Mo 03.10.05 12:50 
Hallo,

Indem du die Shell per cmd /K direkt aufrufst:
ausblenden Delphi-Quelltext
1:
  ShellExecute(0nil, PChar('cmd.exe'), PChar('/K tracert 192.168.80.25'), nil, SW_NORMAL);					

der tracert Befehl wird hier dann per Parameter übergeben.

Gruß,
raziel

_________________
JSXGraph
holger Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 46

W2K pro, XP pro
Delphi 6, Delphi 2007
BeitragVerfasst: Mo 03.10.05 13:22 
Das Funktioniert.

Danke, Danke.
Amiga-Fan
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 534



BeitragVerfasst: Mo 03.10.05 13:59 
ah danach hatte ich hier auch gefragt (wie man es macht, das das Konsolenfenster nicht sofort geschlossen wird):

www.delphi-forum.de/...42805&highlight=

aber gut, weiß ich es jetzt...

_________________
- Leg dich nie mit einem Berufsprogrammierer an
- Wahre Profis akzeptieren keine einfachen Lösungen
CodexX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Di 27.02.07 19:05 
Da ich eine darauf aufbauende Frage habe, stell eich sie hier, statt ein neues Topic zu eröffnen.

/K hält zwar das Fenster offen, jedoch kommt am Ende die Zeile für eine Eingabeaufforderung. Mir wäre es jedoch lieber hier ein "Press any key..." zu sehen und das Fenster dann per Tastendruck zu schließen. In einer Batch-Datei wäre das einfach mit "@pause" machbar. Dazu müsste man bei Shellexecute jedoch zwei Befehle übergeben können, die nacheinander ausgeführt werden.
Lässt sich das irgendwie realisieren?

(Versuche in der Art von '/K tracert 192.168.80.25' +#10#13 + '@pause' scheiterten leider.)
Chatfix
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1583
Erhaltene Danke: 10

Win 10, Win 8, Win 7, Win Vista, Win XP
VB.net (VS 2015), MsSQL (T-SQL), HTML, CSS, PHP, MySQL
BeitragVerfasst: Di 27.02.07 20:11 
dann schreib doch eine .BAT-Datei und führe die aus.
Dann kannst du ale Befehle dort reinpacken die du brauchst ;)

_________________
Gehirn: ein Organ, mit dem wir denken, daß wir denken. - Ambrose Bierce
CodexX
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 118

WinXP
Delphi XE
BeitragVerfasst: Mi 28.02.07 01:42 
Also das soll schon ohne Extra-Dateien auskommen. Der Inhalt ist dynamisch und müsste als temporäre Datei zusammengesetzt werden, ausgeführt und wieder gelöscht. Nene, das ist zum umständlich. Ich möchte ja nur wissen, ob das mit einem Trick machbar ist oder ob ich dafür wirklich auf eine Extra-Komponente wie TDosCommand zurückgreifen muss.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19312
Erhaltene Danke: 1747

W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 28.02.07 08:13 
Ja

Denn das geht nur z.B. mit CreateProcess + Pipes, und da sind wir wieder bei TDosCommand... ;-)
Aber wo ist dabei das Problem?