{"id":3482,"date":"2023-03-02T09:54:59","date_gmt":"2023-03-02T08:54:59","guid":{"rendered":"https:\/\/www.mariotti.de\/?p=3482"},"modified":"2023-03-02T09:54:59","modified_gmt":"2023-03-02T08:54:59","slug":"mit-powershell-einen-prozess-starte-und-zu-lange-laufzeit-erkennen","status":"publish","type":"post","link":"https:\/\/dev.mariotti.de\/?p=3482","title":{"rendered":"Mit PowerShell einen Prozess starte und zu lange Laufzeit erkennen"},"content":{"rendered":"<p>Hier ein simples Beispiel, wie man mittels PowerShell einen Prozess starten kann, und wenn er zu lange l\u00e4uft, dies erkennen und drauf reagieren kann.<\/p>\n<pre><code class=\"language-powershell\">$MaxWaitTime=5000 # in ms\n$Executable='Notepad.exe'\n$ProcessStartInfo=New-Object System.Diagnostics.ProcessStartInfo\n$ProcessStartInfo.FileName=$Executable\n$Process=New-Object System.Diagnostics.Process\n$Process.StartInfo=$ProcessStartInfo\n$Process.Start() | Out-Null\nif ($Process.WaitForExit($MaxWaitTime) -ne $true) { Throw \"Process timeout\" }<\/code><\/pre>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hier ein simples Beispiel, wie man mittels PowerShell einen Prozess starten kann, und wenn er zu lange l\u00e4uft, dies erkennen und drauf reagieren kann. $MaxWaitTime=5000 # in ms $Executable=&#8217;Notepad.exe&#8216; $ProcessStartInfo=New-Object System.Diagnostics.ProcessStartInfo $ProcessStartInfo.FileName=$Executable $Process=New-Object System.Diagnostics.Process $Process.StartInfo=$ProcessStartInfo $Process.Start() | Out-Null if ($Process.WaitForExit($MaxWaitTime) -ne $true) { Throw &#8222;Process timeout&#8220; } &nbsp; &nbsp;<\/p>\n","protected":false},"author":2,"featured_media":2425,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37],"tags":[],"class_list":["post-3482","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3482","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3482"}],"version-history":[{"count":0,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/posts\/3482\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=\/wp\/v2\/media\/2425"}],"wp:attachment":[{"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dev.mariotti.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}