Determine if only one instance is running: Difference between revisions
Determine if only one instance is running (view source)
Revision as of 04:09, 19 May 2016
, 8 years agono edit summary
No edit summary |
|||
Line 710:
-> 30817 # A successful call returns the PID</lang>
A second application trying to acquire the same mutex would receive 'NIL'
=={{header|PowerShell}}==
<lang PowerShell>
if (Get-Process -Name "notepad" -ErrorAction SilentlyContinue)
{
Write-Warning -Message "notepad is already running."
}
else
{
Start-Process -FilePath C:\Windows\notepad.exe
}
</lang>
No output because notepad.exe was not running, so it was started.
{{Out}}
<pre>
</pre>
Run it again.
<lang PowerShell>
if (Get-Process -Name "notepad" -ErrorAction SilentlyContinue)
{
Write-Warning -Message "notepad is already running."
}
else
{
Start-Process -FilePath C:\Windows\notepad.exe
}
</lang>
Since it is running a warning message is output.
{{Out}}
<pre>
WARNING: notepad is already running
</pre>
=={{header|PureBasic}}==
|