getDayzInstallPath.cmd 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. @echo off
  2. ::由于cmd环境的不同,utf8字符集的文件在命令行中执行时中文会出现乱码
  3. ::因此所有的回显内容都使用英文
  4. ::CODER BY Mr.Yu POWERD BY iBAT
  5. ::date: 2022/07/13
  6. set RegPath=HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
  7. reg query %RegPath% |findstr /c:"Steam App 221100">nul 2>nul
  8. if %errorlevel% neq 0 (
  9. goto :findSteamPath
  10. )
  11. for /f "tokens=1,2 delims=:" %%i in ('reg query "%RegPath%\Steam App 221100" /v "InstallLocation" ^|find "InstallLocation"') do (
  12. set desc=From Regedit
  13. set Device=%%i
  14. set "DayzPath=%%j"
  15. )
  16. set DayzPath=%Device:~-1%:%DayzPath%
  17. goto :next
  18. :findSteamPath
  19. if "%PROCESSOR_ARCHITECTURE%" == "AMD64" (
  20. set RegPath=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam
  21. ) else (
  22. goto :notFind
  23. )
  24. for /f "tokens=3 delims= " %%i in ('reg query "%RegPath%" /v "InstallPath"') do (
  25. set "SteamPath=%%i"
  26. )
  27. set "libraryPath=%SteamPath%\steamapps\libraryfolders.vdf"
  28. for /f "delims=" %%i in ('type "%libraryPath%" ^|find "path"') do (
  29. for /f "tokens=2 delims= " %%j in ('echo %%i') do (
  30. if exist %%j\steamapps\common\DayZ (
  31. set desc=From config
  32. set "DayzPath=%%~j\steamapps\common\DayZ"
  33. goto :next
  34. )
  35. )
  36. )
  37. goto :notFind
  38. :next
  39. set DayzPath=%DayzPath:\\=\%
  40. @REM echo GamePath = [%desc%: %DayzPath%]
  41. call .\SetUp.bat "%DayzPath%"
  42. goto :eof
  43. :notFind
  44. cls
  45. if Exist ".\tmp\dayzInstallPath.tmp" (
  46. set "DayzPath="
  47. for /f "delims=" %%i in ('type .\tmp\dayzInstallPath.tmp') do set "DayzPath=%%i"
  48. goto :continue
  49. )
  50. set desc=Get it manually
  51. echo [No installation directory for DayZ was found, please set it manually!]
  52. echo.
  53. @REM 请将dayz的安装目录文件夹拖动到此窗口
  54. set /p "DayzPath=Please drag and drop the DayZ folder to this window:"
  55. :continue
  56. if "%DayzPath%" equ "" (
  57. echo [Fail]The path is empty, end the run, press any key to exit!
  58. pause >nul 2>nul
  59. goto :eof
  60. ) else if not exist "%DayzPath%" (
  61. echo [Fail]The path you entered does not exist, please re-enter it!
  62. choice /t 3 /c ync /d y >nul
  63. del /F/Q ".\tmp\dayzInstallPath.tmp"
  64. goto :notFind
  65. )
  66. echo %DayzPath%|findstr /E "DayZ" 2>nul >nul
  67. if %errorlevel% neq 0 (
  68. echo [Fail]The path you entered is not the game installation directory, please re-enter it!
  69. choice /t 3 /c ync /d y >nul
  70. del /F/Q ".\tmp\dayzInstallPath.tmp"
  71. goto :notFind
  72. )
  73. @REM echo [Successful] enjoy it!
  74. echo %DayzPath%>".\tmp\dayzInstallPath.tmp"
  75. goto :next