How to tell if a process with a certain name is running in an ant script

<target name="posgresql-validate">
		<exec executable="tasklist" outputproperty="output">
			<arg value="/FI"/>
			<arg value="&quot;IMAGENAME eq postgres.exe&quot;"/>
		</exec>
		<condition property="postgres.running">
			<contains string="${output}" substring="postgres.exe"/>
		</condition>
		<fail unless="postgres.running">
			Postgres is not running.  Please install and start postgres.
		</fail>
	</target>

Thanks to Ivor for telling me about the tasklist command.

It's only fair to share...
Share on FacebookGoogle+Tweet about this on TwitterShare on LinkedIn

Leave a Reply