Even simpler, why not use:
Process[] procs = Process.GetProcessByName("Flash");
if (procs.Length > 0)
{
//One or more instances running - Do whatever
}
"Martin Thornalley" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED] 12/08/2005 14:50
|
To: <nant-users@lists.sourceforge.net> cc: Subject: RE: [Nant-users] Query process |
Here's a short script I've written to query if a process called 'Flash' is running. It's very complex but just for completeness I thought I'd post it back.
Martin.
<script language="C#">
<imports>
<import namespace="System.Diagnostics" />
</imports>
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
foreach (Process proc in Process.GetProcesses( ))
{
if (proc.ProcessName == "Flash")
{
// set property to true
project.Properties["wait"] = "true";
}
}
}
]]>
</code>
</script>
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Maggs
Sent: 11 August 2005 17:36
To: nant-users@lists.sourceforge.net
Subject: RE: [Nant-users] Query process
Apologies I replied to the wrong message, this should have been the reply to Martin's message entitled 'Write to registry'
Kind Regards
Andy Maggs
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Andy Maggs
Sent: 11 August 2005 17:22
To: [EMAIL PROTECTED]; nant-users@lists.sourceforge.net
Subject: RE: [Nant-users] Query process
Hi Martin,
We use a script task to write to the registry as follows:
<script language="C#">
<imports>
<import namespace="Microsoft.Win32" />
</imports>
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
RegistryKey key = null;
try
{
key = Registry.LocalMachine.CreateSubKey("Software\\XYZ\\ABC\\1.0\\");
if(key != null)
{
string buildFolder = Path.Combine(project.BaseDirectory, project.Properties["release.dir"]);
key.SetValue("ABCPath", buildFolder);
key.SetValue("ABCDataPath", buildFolder + "\\Data");
}
}
finally
{
if(key != null)
{
key.Close();
}
}
}
]]>
</code>
</script>
Kind Regards
Andy Maggs
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Martin Thornalley
Sent: 11 August 2005 12:49
To: nant-users@lists.sourceforge.net
Subject: [Nant-users] Query process
Is there a way with either a NAnt task or a NAntContrib task to query if a particular process is running?
Thanks,
Martin
As detailed in the company handbook, Avon Insurance has the facility to
monitor and read both incoming and outgoing communications by e-mail.
A copy of the company handbook can be found here: http://www.ho.nfumutual.co.uk/mutualnet/HANDBOOK/ITPolicies/ITSecure.htm
IMPORTANT
The information contained in this e-mail and any attachments is intended for the addressee only
and may contain legally privileged or confidential information. If you are not the intended
recipient you must not use, disclose, copy, distribute, alter, or take any action in reliance
on the information and Avon Insurance plc will not accept liability for any loss or damage howsoever
arising, directly or indirectly in reliance on it and gives no warranty or representation as to its
accuracy or reliability. If you are not the addressee, please notify us immediately on 01789 202121*
and delete the material from your computer and destroy any copies.
Avon Insurance plc reserves the right to monitor and record incoming and outgoing email messages for
the purposes of investigating or detecting unauthorised use of its system and ensuring its effective operation.
Avon Insurance plc will not accept liability for any loss or damage as a result of any virus being passed on.
Avon Insurance plc (No. 209606).
Registered in England. Registered Office: Arden Street, Stratford upon Avon, Warwickshire CV37 6WA.
Authorised and regulated by the Financial Services Authority.
A member of the NFU Mutual group of companies and the Association of British Insurers.
*For security and training purposes, telephone calls may be recorded and monitored.