Set PowerPointProcessList = GetObject("winmgmts:").ExecQuery("select * from win32_process where name='POWERPNT.EXE'")

Dim objPPT, objPresentation, currentPresentation
Dim pptFilePath, isPlay
objPPT = "False"
pptFilePath = WScript.Arguments(0)
isPlay = WScript.Arguments(2)
pptFilePath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(pptFilePath)
Set objPPT = CreateObject("PowerPoint.Application")

Dim isOpen
isOpen = False
For Each objPresentation In objPPT.Presentations
	If CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(objPresentation.FullName) = pptFilePath Then
		Set currentPresentation = objPresentation
		isOpen = True
		Exit For
	End If
Next


If isOpen Then
	Dim currentSlideShow
	currentSlideShow = "False"
	On Error Resume Next
	Set currentSlideShow = currentPresentation.SlideShowWindow
	On Error GoTo 0
	
	If TypeName(currentSlideShow) = "String" Then
		
		currentPresentation.SlideShowSettings.Run
	Else
		currentSlideShow.View.Exit()
	End If
	
Else
	On Error Resume Next
	Set objPresentation = objPPT.Presentations.Open(pptFilePath)
	If isPlay = "true" Then
		objPresentation.SlideShowSettings.Run
	End If
	
	On Error GoTo 0
End If

Set WshShell = CreateObject("WScript.Shell")

For Each objProcess In PowerPointProcessList
	WshShell.AppActivate(objProcess.ProcessId)
	Exit For
Next

Set objPresentation = Nothing
Set objPPT = Nothing