Advertisement
npocmaka

OfficeVersion.bat

Oct 2nd, 2013
270
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 2.05 KB | None | 0 0
  1. @echo off
  2. :office_ver
  3. setlocal enableDelayedExpansion
  4. echo %~1 | find /i "help" >nul 2>&1 && ( goto :help )
  5.  
  6. for /f "tokens=2 delims==" %%O in ('ftype ^|findstr /r /I "\\OFFICE[0-9]*" 2^>nul') do (
  7.     set "verp=%%~O"
  8.     goto :end_for
  9. )
  10. :end_for
  11.  
  12. for %%P in (%verp%) do (
  13.     set "off_path=%%~dpP"
  14.     for %%V in ("!off_path:~0,-1!") do (
  15.  
  16.      set "office_version=%%~nV"
  17.      goto :end_for2
  18.     )
  19. )
  20. :end_for2
  21.  
  22. echo internal version: %office_version%
  23. echo %office_version% | find /i "office7" >nul 2>&1&& (
  24.     echo "Office 97"
  25.     if "%~1" neq "" ( endlocal & set "%~1=Office 97"
  26.     exit /b 0
  27.     )
  28. )
  29. echo %office_version% | find /i "office8" >nul 2>&1 && (
  30.     echo "Office XP"
  31.     if "%~1" neq "" ( endlocal & set "%~1=Office XP"
  32.     exit /b 0
  33.     )
  34. )
  35. echo %office_version% | find /i "office9" >nul 2>&1 && (
  36.     echo "Office 2000"
  37.     if "%~1" neq "" ( endlocal & set "%~1=Office 2000"
  38.     exit /b 0
  39.     )
  40. )
  41. echo %office_version% | find /i "office10" >nul 2>&1 && (
  42.     echo "Office XP"
  43.     if "%~1" neq "" ( endlocal & set "%~1=Office XP"
  44.     exit /b 0
  45.     )
  46. )
  47. echo %office_version% | find /i "office11" >nul 2>&1 && (
  48.     echo "Office 2003"
  49.     if "%~1" neq "" ( endlocal & set  "%~1=Office 2003"
  50.     exit /b 0
  51.     )
  52. )
  53. echo %office_version% | find /i "office12" >nul 2>&1 && (
  54.     echo "Office 2007"
  55.     if "%~1" neq "" ( endlocal & set "%~1=Office 2007"
  56.     exit /b 0
  57.     )
  58. )
  59. echo %office_version% | find /i "office14" >nul 2>&1 && (
  60.     echo "Office 2010"
  61.     if "%~1" neq ""  ( endlocal & set "%~1=Office 2010"
  62.     exit /b 0
  63.     )
  64. )
  65. echo %office_version% | find /i "office15" >nul 2>&1 && (
  66.     echo "Office 2013"
  67.     if "%~1" neq ""  ( endlocal & set "%~1=Office 2013"
  68.     exit /b 0
  69.     )
  70. )
  71. endlocal
  72. goto :eof
  73. rem MAPPING:
  74. rem Office 97   -  7.0
  75. rem Office 98   -  8.0
  76. rem Office 2000 -  9.0
  77. rem Office XP   - 10.0
  78. rem Office 2003 - 11.0
  79. rem Office 2007 - 12.0
  80. rem Office 2010 - 14.0
  81. rem Office 2013 - 15.0
  82. :help
  83. echo %~n0 - displays current microsoft office version
  84. echo %~n0 [RtnVar]
  85. echo(
  86. RtnVar - stores result in variable RtnVar
  87. echo(
  88. echo by Vasil "npocmaka" Arnaudov
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement