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;"/>
		<condition property="postgres.running">
			<contains string="${output}" substring="postgres.exe"/>
		<fail unless="postgres.running">
			Postgres is not running.  Please install and start postgres.

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