Autor Beitrag
master147
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Do 21.02.13 18:23 
Hallo,

ich bin dabei ein Programm zu schreiben, dass Windows Programme automatisch installiert. Nun habe ich aber ein kleines Problem:
Wenn ich dass Programm mit
Process.start("cmd"" / c " + installpath +" / "Parameter)

dann funktioniert die Installation. Allerdings weiß ich nicht wann der Prozess fertig ist. Deshalb habe ich dass ganze mit
ausblenden C#-Quelltext
1:
2:
3:
4:
5:
Process test = new Process()
test.FileInfo.start("cmd / c " + installpath);
test.FileInfo.Arguments=" / " + Parameter;
test.start();
test.WaitforExit();


probiert. Weil ja eigentlich WaitforExit() wartet bis der Prozess fertig ist. Dies funktioniert aber nicht.
Dann öffnet sich zwar das Installationsfenster, aber Der Parameter wird nicht mitgegeben.

Wisst ihr wie ich den geöffneten Prozess überwachen kann und beim schließen dieses Prozess mit dem restlichen Quellcode weitermachen kann ?

Vielen Dank für eure Mühe
Ralf Jansen
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 4708
Erhaltene Danke: 991


VS2010 Pro, VS2012 Pro, VS2013 Pro, VS2015 Pro, Delphi 7 Pro
BeitragVerfasst: Do 21.02.13 19:36 
Dein Process.Start Aufruf liefert dir eine Process Instanz zurück. Da kannst du genauso dein WaitforExit() aufrufen.

Dein 2.ter Code wird wohl nicht funktionieren weil die Parameter so bei cmd landen und nicht bei dem Programm das sich hinter installpath versteckt. installPath+Parameter gehört zusammen und sind die Argumente von cmd so wie du es auch in Code 1 gemacht hast da ist das ganze Zeug ja auch noch Argument von cmd.
Th69
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Moderator
Beiträge: 4798
Erhaltene Danke: 1059

Win10
C#, C++ (VS 2017/19/22)
BeitragVerfasst: Do 21.02.13 20:16 
Hallo zusammen,

zwischen dem Slash und dem Parameter darf aber kein Leerzeichen sein, also
ausblenden C#-Quelltext
1:
2:
Process process = Process.Start("cmd""/c " + installpath + " /" + Parameter);
process.WaitForExit();
master147 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 32



BeitragVerfasst: Do 21.02.13 21:19 
Vielen Dank, dass hat super funktioniert