<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to close external programs? in DIAdem</title>
    <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394409#M4635</link>
    <description>Hi there,&lt;BR /&gt;
in vbs is a command "ExtProgram(ExtProgramName, ExtProgramArg)" to
start external programs. But how to&amp;nbsp; close external programs when
they finished its work? Is there a vbs-command for it? Is there a way
when calling "cmd.exe" with a proper parameter?&lt;BR /&gt;
&lt;BR /&gt;
Martin Bohm&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Fri, 21 Jul 2006 07:45:15 GMT</pubDate>
    <dc:creator>bohm</dc:creator>
    <dc:date>2006-07-21T07:45:15Z</dc:date>
    <item>
      <title>How to close external programs?</title>
      <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394409#M4635</link>
      <description>Hi there,&lt;BR /&gt;
in vbs is a command "ExtProgram(ExtProgramName, ExtProgramArg)" to
start external programs. But how to&amp;nbsp; close external programs when
they finished its work? Is there a vbs-command for it? Is there a way
when calling "cmd.exe" with a proper parameter?&lt;BR /&gt;
&lt;BR /&gt;
Martin Bohm&lt;BR /&gt;
&lt;BR /&gt;
&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Jul 2006 07:45:15 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394409#M4635</guid>
      <dc:creator>bohm</dc:creator>
      <dc:date>2006-07-21T07:45:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to close external programs?</title>
      <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394415#M4636</link>
      <description>Hello Martin!&lt;BR /&gt;&lt;BR /&gt;For a 'good' solution you have to call the external program in a way that it will exit after finishing work. Another way - if implemented - is to start the external program as a OLE server.&lt;BR /&gt;&lt;BR /&gt;If this isn't possible you have to be more violent. On Windows XP there is a small tool 'taskkill.exe'. Call this program with parameters wich will identify the external program (e.g. Programm name) and it will be aborted (no common exit!). Note I: You have to be shure that the work was already finished. Note II: This will abort all runing instances of this program!&lt;BR /&gt;&lt;BR /&gt;Example 'taskkill.exe' call to 'exit' DIAdem:&lt;PRE style="background-color: #FFFFFF"&gt;&lt;CODE&gt;&lt;FONT size="2" face="Courier New"&gt;&lt;FONT color="#000000"&gt;C:\WINDOWS\system32\taskkill.exe /F /IM DIAdem.exe&lt;BR /&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;FONT&gt;&lt;/FONT&gt;&lt;/PRE&gt;See M$ help for parameter usage or use -? parameter&lt;BR /&gt;&lt;BR /&gt;Matthias</description>
      <pubDate>Fri, 21 Jul 2006 08:02:04 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394415#M4636</guid>
      <dc:creator>Twigeater</dc:creator>
      <dc:date>2006-07-21T08:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to close external programs?</title>
      <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394466#M4638</link>
      <description>&lt;FONT size="4"&gt;Thank you for the hint, it helps. &lt;BR /&gt;
Is there a command to check if a certain program is still running?&lt;BR /&gt;
&lt;BR /&gt;
Martin Bohm&lt;BR /&gt;
&lt;/FONT&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 21 Jul 2006 09:58:23 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394466#M4638</guid>
      <dc:creator>bohm</dc:creator>
      <dc:date>2006-07-21T09:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to close external programs?</title>
      <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394569#M4645</link>
      <description>Hello Martin!&lt;BR /&gt;&lt;BR /&gt;Yes, with the tool 'tasklist' in the same directory.&lt;BR /&gt;&lt;BR /&gt;The problem is that it is not easy to query from script. I tried it in the following script. Perhaps not perfect espacially because a command interpreter pop up every time you call the function.&lt;PRE style="background-color: #FFFFE1"&gt;&lt;CODE&gt;&lt;FONT size="2" face="Courier New"&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Option Explicit&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;If &lt;/B&gt;IsDIAdemRunning&lt;I&gt;() &lt;/I&gt;&lt;B&gt;Then&lt;BR /&gt;  Call &lt;/B&gt;MsgBox&lt;I&gt;( &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"At least one DIAdem is running!" &lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&lt;/I&gt;&lt;B&gt;Else&lt;BR /&gt;  Call &lt;/B&gt;MsgBox&lt;I&gt;( &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"No DIAdem at all!" &lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&lt;/I&gt;&lt;B&gt;End If&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Function &lt;/B&gt;IsDIAdemRunning&lt;I&gt;()&lt;BR /&gt;  &lt;/I&gt;&lt;B&gt;Dim &lt;/B&gt;oWshShell&lt;BR /&gt;  &lt;B&gt;Dim &lt;/B&gt;oExec&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;  &lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' Execute via Shell Object&lt;BR /&gt;  &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Set &lt;/B&gt;oWshShell &lt;I&gt;= &lt;/I&gt;CreateObject&lt;I&gt;(&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"WScript.Shell"&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;  &lt;/I&gt;&lt;B&gt;Set &lt;/B&gt;oExec &lt;I&gt;= &lt;/I&gt;oWshShell&lt;I&gt;.&lt;/I&gt;Exec&lt;I&gt;( &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"C:\windows\system32\tasklist.exe /FI ""IMAGENAME eq DIAdem.exe"""&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;  &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' wait until tasklist is finished&lt;BR /&gt;  &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Do While &lt;/B&gt;oExec&lt;I&gt;.&lt;/I&gt;Status &lt;I&gt;= &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;0&lt;BR /&gt;    &lt;/FONT&gt;&lt;FONT color="#000080"&gt;Pause&lt;I&gt;(&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;1&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;  &lt;/I&gt;&lt;B&gt;Loop&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;  &lt;/B&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' no Standard Output -&amp;gt; no DIAdem running&lt;BR /&gt;  &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;IsDIAdemRunning &lt;I&gt;= &lt;/I&gt;Len&lt;I&gt;(&lt;/I&gt;oExec&lt;I&gt;.&lt;/I&gt;StdOut&lt;I&gt;.&lt;/I&gt;ReadAll&lt;I&gt;) &amp;lt;&amp;gt; &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;0&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;End Function&lt;BR /&gt;&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;A better solution might be possible via WMI. &lt;BR /&gt;&lt;BR /&gt;Matthias</description>
      <pubDate>Fri, 21 Jul 2006 13:53:39 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394569#M4645</guid>
      <dc:creator>Twigeater</dc:creator>
      <dc:date>2006-07-21T13:53:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to close external programs?</title>
      <link>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394873#M4647</link>
      <description>Hello Martin!&lt;BR /&gt;&lt;BR /&gt;Now I had the time to look for the solution with WMI. You have to be shure that it is allowed/possible to use WMI on the target computer. This solution is faster and more reliable compared to the taskkill/tasklist solutions.&lt;BR /&gt;&lt;BR /&gt;The script shows how to get the processlist for a specific EXE. It prints the count wich you can use to find out if a process is running and then termiante all running instances of this EXE.&lt;PRE style="background-color: #FFFFE1"&gt;&lt;CODE&gt;&lt;FONT size="2" face="Courier New"&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Option Explicit&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;Dim &lt;/B&gt;oWMI&lt;BR /&gt;&lt;B&gt;Dim &lt;/B&gt;oProcessList&lt;BR /&gt;&lt;B&gt;Dim &lt;/B&gt;oProcess&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' Get WMI for the local computer&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Set &lt;/B&gt;oWmi &lt;I&gt;= &lt;/I&gt;GetObject&lt;I&gt;(&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2"&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' Query process list&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Set &lt;/B&gt;oProcessList &lt;I&gt;= &lt;/I&gt;oWmi&lt;I&gt;.&lt;/I&gt;ExecQuery&lt;I&gt;(&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;"Select * from Win32_Process Where Name = 'DIAdem.exe'"&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' Print running processes count&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;Call &lt;/B&gt;MsgBox&lt;I&gt;( &lt;/I&gt;oProcessList&lt;I&gt;.&lt;/I&gt;Count &lt;I&gt;&amp;amp; &lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#FF0000"&gt;" DIAdem.exe instances are running"&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;I&gt;)&lt;BR /&gt;&amp;nbsp;&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#008000"&gt;&lt;I&gt;' Terminate all runing processes&lt;BR /&gt;&lt;/I&gt;&lt;/FONT&gt;&lt;FONT color="#000080"&gt;&lt;B&gt;For Each &lt;/B&gt;oProcess &lt;B&gt;in &lt;/B&gt;oProcessList&lt;BR /&gt;  oProcess&lt;I&gt;.&lt;/I&gt;Terminate&lt;I&gt;()&lt;/I&gt;&lt;BR /&gt;&lt;B&gt;Next&lt;/B&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/CODE&gt;&lt;/PRE&gt;Matthias</description>
      <pubDate>Sat, 22 Jul 2006 05:43:32 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/DIAdem/How-to-close-external-programs/m-p/394873#M4647</guid>
      <dc:creator>Twigeater</dc:creator>
      <dc:date>2006-07-22T05:43:32Z</dc:date>
    </item>
  </channel>
</rss>

