Jump to content

Determine if only one instance is running: Difference between revisions

no 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}}==
308

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.