Skip to content

Instantly share code, notes, and snippets.

@heiths
Created August 18, 2012 23:14
Show Gist options
  • Save heiths/3390293 to your computer and use it in GitHub Desktop.
Save heiths/3390293 to your computer and use it in GitHub Desktop.
ensure that only a single instance of maya is running on windows.
'Be sure that maya's bin folder is located in your system's path.
Dim AllProcess, Process, strFoundProcess
Dim objShell : Set objShell = CreateObject("Wscript.Shell")
strFoundProcess = False
Set AllProcess = getobject("winmgmts:") 'create object
objShell.Run "maya.exe"
WScript.Sleep 4000
Do
For Each Process In AllProcess.InstancesOf("Win32_process") 'Get all the processes running in your PC
If (Instr (Ucase(Process.Name),"maya.exe") = 1) then
objShell.Run "taskkill /IM maya.exe",1,True 'if app is running
strFoundProcess = True
End If
Next
Loop until strFoundProcess = True
If strFoundProcess = False Then
objShell.Run "maya.exe"
End If
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment