Autor Beitrag
Siluro
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Mo 08.01.07 18:57 
Hi,
ich hab ein kleines Problem mit Shellexecute. Ich möchte eine Batchdatei mit folgendem Inhalt starten:
ausblenden Quelltext
1:
java -cp server.jar;pg80b1.308.jdbc3.jar jbsoft.Server.JBServer --with-gui					


Ich versuche die Datei mit folgendem Quellcode zu starten:
ausblenden Delphi-Quelltext
1:
2:
if ShellExecute(h, 'open', PAnsiChar(batfile), nil, nil, SW_SHOWNORMAL)<32 then
      showmessage('Servers der Lizenzen nicht stared');


Mein Problem ist jetzt, das die Batchdatei nicht zuende ausgeführt wird. Sie wird zwar kurz gestartet, aber gleich wieder beendet. Wenn ich sie manuell starte ist alles in Ordnung.
Ich hoffe mir kann jemand helfen.

Danke im vorraus.

Björn
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Mo 08.01.07 23:00 
Moin!

Was steht denn in batfile? Wenn das der Pfad mit den Parametern ist, dann kann das auch nicht gehen, du mußt die Parameter an das Programm separat übergeben. Schau mal nach Beispielen zu Suche in: Delphi-Forum, Delphi-Library SHELLEXECUTE, gibt genug dazu. ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Di 09.01.07 00:39 
So wie ich das sehe, benutzt er in seiner Batch-Datei keine %1 etc. also werden wohl keine Parameter übergeben, dann denk ich, dass in batfile bloß der Pfad zur *.bat sowie der Dateiname stehn.

Aber das würde ja auch ohne *.bat gehn denk ich.
ShellExecute(0, 'open', PChar('java'), PChar('-cp server.jar;pg80b1.308.jdbc3.jar jbsoft.Server.JBServer --with-gui'),nil,SW_SHOWNORMAL); mal ausprobieren? Mag sein, dass du die java-Exe mit direktem Pfad brauchst, aber ich denk so müssts auch gehn, ohne Batch datei...

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
hansa
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3079
Erhaltene Danke: 9



BeitragVerfasst: Di 09.01.07 01:08 
Wozu ist denn die BAT überhaupt da ?

_________________
Gruß
Hansa
Harry M.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 754

Win 2000, XP
D2005
BeitragVerfasst: Di 09.01.07 09:31 
Ich denke es liegt am Arbeitsverzeichnis in dem die Bat ausgeführt wird.
ausblenden Delphi-Quelltext
1:
2:
if ShellExecute(h, 'open', PAnsiChar(ExtractFileName(batfile), nil, PAnsiChar(ExtractFilePath(batfile)), SW_SHOWNORMAL)<32 then 
      showmessage('Servers der Lizenzen nicht stared');

_________________
Gruß Harry
Et spes me per dies sine te ducat et amor me ferat, si dolor spem tollit.
Siluro Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 74

Win XP Prof., Win XP64 Prof., Win 7 Prof.
Delphi 7 Ent., Delphi XE, Delphi XE5
BeitragVerfasst: Di 09.01.07 11:06 
Danke für die schnelle Hilfe, habs jetzt mit der Lösung von Harry hinbekommen.