2009-09-12, 02:11 AM
I set up one of my remote's buttons to start pvrx2 but if pvrx2 was already running it would create a new process and then switch me to the old process. I ended up with alot of pvrx2 processes if I kept hitting the button. Here's a little script that will check to see if pvrx2 is running and if it is activate it, a.k.a. bring it to the forefront. If it's not running, it will start it.
Not very complex. Save it to a file with a vbs extension and put it in the same directory as PVRX2.
Code:
strComputer = "."
strProgramName = "PVRX2.exe"
strProgramTitle = "PVRX2"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("WScript.Shell")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = '" & strProgramName & "'")
If colProcessList.Count > 0 Then
objShell.appactivate strProgramTitle
Else
objShell.Run strProgramName
End If
Not very complex. Save it to a file with a vbs extension and put it in the same directory as PVRX2.