diff --git a/sp/run.bat b/sp/run.bat index 367dc66e5..8ab651959 100644 --- a/sp/run.bat +++ b/sp/run.bat @@ -1 +1,35 @@ -@start /D "%ProgramFiles(x86)%\Steam\steamapps\common\Source SDK Base 2013 Singleplayer" hl2.exe -dev -console -novid -game "%CD%\game\sdk2013CE" \ No newline at end of file +@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 diff --git a/sp/shaderedit.bat b/sp/shaderedit.bat index e8309451c..b3bedd2d3 100644 --- a/sp/shaderedit.bat +++ b/sp/shaderedit.bat @@ -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 \ No newline at end of file +@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