using Eplan.EplApi.Scripting; using System.Diagnostics; using System.IO; using System; public class PDF_druck_Anzahl { public string strZielDatei = ""; [Start] public void Function() { int anzahl = 3; int durchlauf = 1; int zeit; zeit = 7000 * durchlauf; strZielDatei = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\Test1.pdf"; int id = 0; FileInfo fileInfo = new FileInfo(strZielDatei); if (!fileInfo.Exists) { throw new FileNotFoundException(); } else { using (Process proc = new Process()) { proc.StartInfo.Verb = "print"; proc.StartInfo.FileName = strZielDatei; proc.StartInfo.CreateNoWindow = true; proc.StartInfo.UseShellExecute = true; proc.StartInfo.ErrorDialog = true; for (durchlauf = 1; durchlauf <= anzahl; durchlauf++) { proc.Start(); } proc.WaitForExit(zeit); id = proc.Id; if (!proc.WaitForExit(zeit)) { killProcessById(id); } } } } private void killProcessById(int id) { foreach (Process p in Process.GetProcesses()) { if (p.Id == id) { p.Kill(); File.Delete(strZielDatei); } } } }