Option Explicit ' RunDemo script ' a script for executing *_DirectToRift.exe with suitable Direct3D argument. ' This is free and unencumbered script released into the public domain. ' ' date: 2014/08/05 ' author: https://twitter.com/cubic9com ' site: http://cubic9.com/Devel/OculusRift/HowToExecuteAppsForDK2MadeWithUnity/ Function IsExtendMode() Dim objWMIService Dim colItems Dim objItem Set objWMIService = GetObject("winmgmts:\\.\root\WMI") Set colItems = objWMIService.ExecQuery( _ "Select UserFriendlyName, UserFriendlyNameLength From WmiMonitorID" _ ) For Each objItem in colItems If objItem.UserFriendlyNameLength > 0 then If BytesToString(objItem.UserFriendlyName) = "Rift DK2" Then IsExtendMode = True End If End If Next End Function Function BytesToString(ByVal bytes) Dim str, n str = "" For n = 0 To UBound(bytes) If CInt(bytes(n)) = 0 Then Exit For Else str = str & Chr(bytes(n)) End If Next BytesToString = str End Function Function GetDirectToRift() Dim objFSO Dim objFolder Dim objFile Set objFSO = WScript.CreateObject("Scripting.FileSystemObject") Set objFolder = objFSO.GetFolder(".") For Each objFile In objFolder.Files If InStrRev(objFile.Name, "_DirectToRift.exe") <> 0 Then GetDirectToRift = objFile.Name End If Next End Function Dim objShell Set objShell = WScript.CreateObject("WScript.Shell") If IsExtendMode() = True Then objShell.Run(GetDirectToRift() & " -force-d3d9") Else objShell.Run(GetDirectToRift() & " -force-d3d11") End If