Improved batch-files

Now they can find where is Steam directory
This commit is contained in:
VXP 2016-09-07 20:46:12 +03:00
parent c22b47fb47
commit 93b2ccd9f4
2 changed files with 71 additions and 2 deletions

View file

@ -1 +1,35 @@
@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE"
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem Getting Steam path from registry
rem for /F "usebackq tokens=2*" %%I in (`reg query "HKCU\Software\Valve\Steam"^|find /I "SteamPath"`) do set steampath=%%J
for /f "usebackq tokens=1,2,*" %%i in (`reg query "HKCU\Software\Valve\Steam" /v "SteamPath"`) do set "steampath=%%~k"
rem Since this is loop, we cannot use ERRORLEVEL here
rem if not ERRORLEVEL 0 goto error
rem Replacing "/"'s with "\" in some cases
set steampath=%steampath:/=\%
rem Testing common paths
if not exist "%steampath%\steam.exe" (
if not exist "%ProgramFiles(x86)%\steam.exe" (
if not exist "%ProgramFiles%\steam.exe" (
goto error
) else (
set steampath=%ProgramFiles%
)
) else set steampath=%ProgramFiles(x86)%
)
echo Running a game
@start /D "%steampath%\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE"
if %ERRORLEVEL% NEQ 0 goto error
goto success
:success
exit
:error
echo Error during launching game!
pause
exit

View file

@ -1 +1,36 @@
@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer\" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" -shaderedit -window -height 720
@echo off
setlocal ENABLEDELAYEDEXPANSION
rem Getting Steam path from registry
rem for /F "usebackq tokens=2*" %%I in (`reg query "HKCU\Software\Valve\Steam"^|find /I "SteamPath"`) do set steampath=%%J
for /f "usebackq tokens=1,2,*" %%i in (`reg query "HKCU\Software\Valve\Steam" /v "SteamPath"`) do set "steampath=%%~k"
rem Since this is loop, we cannot use ERRORLEVEL here
rem if not ERRORLEVEL 0 goto error
rem Replacing "/"'s with "\" in some cases
set steampath=%steampath:/=\%
rem Testing common paths
if not exist "%steampath%\steam.exe" (
if not exist "%ProgramFiles(x86)%\steam.exe" (
if not exist "%ProgramFiles%\steam.exe" (
goto error
) else (
set steampath=%ProgramFiles%
)
) else set steampath=%ProgramFiles(x86)%
)
echo Running a shader editor
@start /D "%steampath%\steamapps\common\Source SDK Base 2013 Singleplayer\" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" -shaderedit -window -height 720
if %ERRORLEVEL% NEQ 0 goto error
goto success
:success
exit
:error
echo Error during launching game!
pause
exit