2013-05-13, 13:37
Ive mucking around with using a batch file to close xbmc, launch a standalone pc game then restart xbmc once the game is closed in Windows. Thanks to fr500 and Johnny4D Ive got a batch file that works very well.
Two VB scripts are needed:
Sleep.vbs
LaunchXBMC.vbs
And the batch files. Lines 3 to 9 need to be edited to suit, Lines 8 + 9 point to the VB scripts and once changed can be left as. These are the two batch files I have used and tested so far.
Dark Souls.bat
Syndicate.bat
Two VB scripts are needed:
Sleep.vbs
Code:
On error resume next
Wscript.Sleep(wscript.arguments(0)*1000)
LaunchXBMC.vbs
Code:
WScript.Sleep(1500)
On Error Resume Next
XBMCPath="""" & wscript.arguments(0) & """"
XBMCParams=wscript.arguments(1)
Dim objShell
Set objShell = WScript.CreateObject ("WScript.shell")
objShell.run XBMCPath & " " & XBMCParams
And the batch files. Lines 3 to 9 need to be edited to suit, Lines 8 + 9 point to the VB scripts and once changed can be left as. These are the two batch files I have used and tested so far.
Dark Souls.bat
Code:
@echo off
set XBMCLaunchCmd="C:\Program Files (x86)\XBMC\XBMC.exe"
set GAMEWorkingDir="e:\games\Dark Souls"
set GAMELaunchCmd="DARKSOULS.exe"
set GAMEProcess="DARKSOULS.exe"
set XBMCPreLaunchCmd=""
set VBSSleep="%appdata%\XBMC\userdata\addon_data\script.games.rom.collection.browser\scriptfiles\Sleep.vbs"
set VBSLaunch="%appdata%\XBMC\userdata\addon_data\script.games.rom.collection.browser\scriptfiles\LaunchXBMC.vbs"
set ignore_result=INFO:
echo Stopping XBMC...
echo.
taskkill /f /IM xbmc.exe>nul 2>nul
REM Give it a second to quit
cscript //B //Nologo %VBSSleep% 1
echo Starting %GAMELaunchCmd%...
echo.
cd /d %GAMEWorkingDir%
%GAMELaunchCmd%
:1
set var=notrunning
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %GAMEProcess%"`) do if not %%A==%ignore_result% set var=running
echo variable %var%
timeout 1
if %var% == notrunning goto :1
:2
set var=notrunning
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %GAMEProcess%"`) do if not %%A==%ignore_result% set var=running
echo variable %var%
timeout 1
if %var% == running goto :2
%XBMCPreLaunchCmd%
REM Restart XBMC
echo Restarting XBMC...
cscript //B //Nologo %VBSLaunch% %XBMCLaunchCmd%
Syndicate.bat
Code:
@echo off
set XBMCLaunchCmd="C:\Program Files (x86)\XBMC\XBMC.exe"
set GAMEWorkingDir="e:\games\origin-games\Syndicate\System\Win32_x86_Release"
set GAMELaunchCmd="Syndicate.exe"
set GAMEProcess="Syndicate.exe"
set XBMCPreLaunchCmd="C:\Windows\System32\taskkill.exe" /F /IM Origin.exe 2>nul
set VBSSleep="%appdata%\XBMC\userdata\addon_data\script.games.rom.collection.browser\scriptfiles\Sleep.vbs"
set VBSLaunch="%appdata%\XBMC\userdata\addon_data\script.games.rom.collection.browser\scriptfiles\LaunchXBMC.vbs"
set ignore_result=INFO:
echo Stopping XBMC...
echo.
taskkill /f /IM xbmc.exe>nul 2>nul
REM Give it a second to quit
cscript //B //Nologo %VBSSleep% 1
echo Starting %GAMELaunchCmd%...
echo.
cd /d %GAMEWorkingDir%
%GAMELaunchCmd%
:1
set var=notrunning
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %GAMEProcess%"`) do if not %%A==%ignore_result% set var=running
echo variable %var%
timeout 1
if %var% == notrunning goto :1
:2
set var=notrunning
for /f "usebackq" %%A in (`tasklist /nh /fi "imagename eq %GAMEProcess%"`) do if not %%A==%ignore_result% set var=running
echo variable %var%
timeout 1
if %var% == running goto :2
%XBMCPreLaunchCmd%
REM Restart XBMC
echo Restarting XBMC...
cscript //B //Nologo %VBSLaunch% %XBMCLaunchCmd%