Advertisement
Wasif_Hasan_

Word2AnyInstall.ps1

Aug 12th, 2020
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Word2AnyInstall.ps1
  2. #This script will install context menus on .DOC,.DOCX,.RTF,.PDF,.HTM,.HTML,.ODT,.XML,.XPS files to convert them to different # format using MS Word
  3. #   Right-click any file in these extensions and you will get a menu abiove "Properties" use it
  4. #   An MSI-based (not Click-To-Run) installation of MS Office is required, will work for Office 2007+ versions and even # Unactivated versions will work too
  5. #   While conversion, just make sure that MS Word is not Open and please don't occupy C:\bin directory where files will be kept
  6.  
  7. $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
  8. if( -not ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)))
  9. {
  10.     Write-Host "Running Admin Shell, Please wait....."
  11.     Start-Sleep -Seconds 1
  12.     Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs
  13.     Exit 0
  14. }
  15.  
  16. function Install {
  17. If (!(Test-Path C:\bin)){
  18.   New-Item C:\bin -Type Directory
  19. }
  20.  
  21. @'
  22. Param(
  23.     [System.IO.Fileinfo]$Source,
  24.     [String]$Format
  25. )
  26. $arrFileExt = @{
  27.      "doc"      =   0
  28.      "docx"     =   0
  29.      "htm"      =   8  
  30.      "html"     =   8
  31.      "odt"      =   23
  32.      "pdf"      =   17 
  33.      "rtf"      =   6
  34.      "txt"      =   4
  35.      "xml"      =   19
  36.      "xps"      =   18
  37. }
  38. $myFileType = $arrFileExt."$Format"
  39. $myFileName = $Source.Basename
  40. $myFileExt = "." + $Format
  41. $toSave = Split-Path "$Source"
  42. $myOutputFile = $toSave + "\" + $myFileName + $myFileExt
  43. $objWord = New-Object -COMObject "Word.Application"
  44. $objWord.Visible = $False
  45. $objWord.Documents.Open([string]$Source) | Out-Null
  46. $objDoc = $objWord.ActiveDocument
  47. $objDoc.SaveAs("$myOutputFile",$myFileType) | Out-Null
  48. $objDoc.Close() | Out-Null
  49. '@ | Set-Content C:\bin\Word2Any.ps1
  50.  
  51. @'
  52. Windows Registry Editor Version 5.00
  53.  
  54. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo]
  55. "MUIVerb"="Convert To"
  56. "Position"="Bottom"
  57. "SubCommands"=""
  58.  
  59. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell]
  60.  
  61. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\001DOC]
  62. "MUIverb"="Word document 1997-2003 (DOC)"
  63. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  64.  
  65. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\001DOC\command]
  66. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  67.  
  68. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\002DOCX]
  69. "MUIVerb"="Word document 2007-2019 (DOCX)"
  70. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  71.  
  72. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\002DOCX\command]
  73. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  74.  
  75. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\003PDF]
  76. "MUIVerb"="Portable Document Format (PDF)"
  77. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  78.  
  79. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\003PDF\command]
  80. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  81.  
  82. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\004RTF]
  83. "MUIVerb"="Rich Text Format (RTF)"
  84. "Icon"="shell32.dll,1"
  85.  
  86. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\004RTF\command]
  87. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  88.  
  89. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\005ODT]
  90. "MUIVerb"="Open Document Text (ODT)"
  91. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  92.  
  93. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\005ODT\command]
  94. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  95.  
  96. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\006TXT]
  97. "MUIVerb"="Plain Text File (TXT)"
  98. "Icon"="shell32.dll,70"
  99.  
  100. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\006TXT\command]
  101. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  102.  
  103. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\007HTM]
  104. "MUIVerb"="HTML webpage (HTM)"
  105. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  106.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  107.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  108.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  109.  35,00,00,00
  110.  
  111. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\007HTM\command]
  112. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  113.  
  114. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\008HTML]
  115. "MUIverb"="HTML webpage ()HTML)"
  116. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  117.  
  118. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\008HTML\command]
  119. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  120.  
  121. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\009XML]
  122. "MUIVerb"="XML File (XML)"
  123. "Icon"="ieframe.dll,2"
  124.  
  125. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\009XML\command]
  126. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  127.  
  128. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\010XPS]
  129. "MUIVerb"="XPS File (XPS)"
  130. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  131.  
  132. [HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\010XPS\command]
  133. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo]
  141. "MUIVerb"="Convert To"
  142. "Position"="Bottom"
  143. "SubCommands"=""
  144.  
  145. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell]
  146.  
  147. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\001DOC]
  148. "MUIverb"="Word document 1997-2003 (DOC)"
  149. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  150.  
  151. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\001DOC\command]
  152. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  153.  
  154. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\002DOCX]
  155. "MUIVerb"="Word document 2007-2019 (DOCX)"
  156. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  157.  
  158. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\002DOCX\command]
  159. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  160.  
  161. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\003PDF]
  162. "MUIVerb"="Portable Document Format (PDF)"
  163. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  164.  
  165. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\003PDF\command]
  166. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  167.  
  168. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\004RTF]
  169. "MUIVerb"="Rich Text Format (RTF)"
  170. "Icon"="shell32.dll,1"
  171.  
  172. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\004RTF\command]
  173. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  174.  
  175. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\005ODT]
  176. "MUIVerb"="Open Document Text (ODT)"
  177. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  178.  
  179. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\005ODT\command]
  180. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  181.  
  182. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\006TXT]
  183. "MUIVerb"="Plain Text File (TXT)"
  184. "Icon"="shell32.dll,70"
  185.  
  186. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\006TXT\command]
  187. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  188.  
  189. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\007HTM]
  190. "MUIVerb"="HTML webpage (HTM)"
  191. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  192.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  193.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  194.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  195.  35,00,00,00
  196.  
  197. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\007HTM\command]
  198. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  199.  
  200. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\008HTML]
  201. "MUIverb"="HTML webpage ()HTML)"
  202. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  203.  
  204. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\008HTML\command]
  205. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  206.  
  207. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\009XML]
  208. "MUIVerb"="XML File (XML)"
  209. "Icon"="ieframe.dll,2"
  210.  
  211. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\009XML\command]
  212. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  213.  
  214. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\010XPS]
  215. "MUIVerb"="XPS File (XPS)"
  216. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  217.  
  218. [HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\010XPS\command]
  219. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo]
  230. "MUIVerb"="Convert To"
  231. "Position"="Bottom"
  232. "SubCommands"=""
  233.  
  234. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell]
  235.  
  236. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\001DOC]
  237. "MUIverb"="Word document 1997-2003 (DOC)"
  238. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  239.  
  240. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\001DOC\command]
  241. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  242.  
  243. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\002DOCX]
  244. "MUIVerb"="Word document 2007-2019 (DOCX)"
  245. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  246.  
  247. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\002DOCX\command]
  248. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  249.  
  250. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\003PDF]
  251. "MUIVerb"="Portable Document Format (PDF)"
  252. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  253.  
  254. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\003PDF\command]
  255. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  256.  
  257. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\004RTF]
  258. "MUIVerb"="Rich Text Format (RTF)"
  259. "Icon"="shell32.dll,1"
  260.  
  261. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\004RTF\command]
  262. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  263.  
  264. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\005ODT]
  265. "MUIVerb"="Open Document Text (ODT)"
  266. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  267.  
  268. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\005ODT\command]
  269. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  270.  
  271. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\006TXT]
  272. "MUIVerb"="Plain Text File (TXT)"
  273. "Icon"="shell32.dll,70"
  274.  
  275. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\006TXT\command]
  276. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  277.  
  278. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\007HTM]
  279. "MUIVerb"="HTML webpage (HTM)"
  280. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  281.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  282.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  283.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  284.  35,00,00,00
  285.  
  286. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\007HTM\command]
  287. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  288.  
  289. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\008HTML]
  290. "MUIverb"="HTML webpage ()HTML)"
  291. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  292.  
  293. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\008HTML\command]
  294. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  295.  
  296. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\009XML]
  297. "MUIVerb"="XML File (XML)"
  298. "Icon"="ieframe.dll,2"
  299.  
  300. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\009XML\command]
  301. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  302.  
  303. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\010XPS]
  304. "MUIVerb"="XPS File (XPS)"
  305. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  306.  
  307. [HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\010XPS\command]
  308. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  309.  
  310.  
  311.  
  312.  
  313. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo]
  314. "MUIVerb"="Convert To"
  315. "Position"="Bottom"
  316. "SubCommands"=""
  317.  
  318. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell]
  319.  
  320. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\001DOC]
  321. "MUIverb"="Word document 1997-2003 (DOC)"
  322. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  323.  
  324. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\001DOC\command]
  325. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  326.  
  327. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\002DOCX]
  328. "MUIVerb"="Word document 2007-2019 (DOCX)"
  329. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  330.  
  331. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\002DOCX\command]
  332. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  333.  
  334. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\003PDF]
  335. "MUIVerb"="Portable Document Format (PDF)"
  336. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  337.  
  338. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\003PDF\command]
  339. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  340.  
  341. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\004RTF]
  342. "MUIVerb"="Rich Text Format (RTF)"
  343. "Icon"="shell32.dll,1"
  344.  
  345. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\004RTF\command]
  346. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  347.  
  348. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\005ODT]
  349. "MUIVerb"="Open Document Text (ODT)"
  350. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  351.  
  352. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\005ODT\command]
  353. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  354.  
  355. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\006TXT]
  356. "MUIVerb"="Plain Text File (TXT)"
  357. "Icon"="shell32.dll,70"
  358.  
  359. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\006TXT\command]
  360. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  361.  
  362. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\007HTM]
  363. "MUIVerb"="HTML webpage (HTM)"
  364. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  365.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  366.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  367.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  368.  35,00,00,00
  369.  
  370. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\007HTM\command]
  371. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  372.  
  373. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\008HTML]
  374. "MUIverb"="HTML webpage ()HTML)"
  375. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  376.  
  377. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\008HTML\command]
  378. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  379.  
  380. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\009XML]
  381. "MUIVerb"="XML File (XML)"
  382. "Icon"="ieframe.dll,2"
  383.  
  384. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\009XML\command]
  385. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  386.  
  387. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\010XPS]
  388. "MUIVerb"="XPS File (XPS)"
  389. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  390.  
  391. [HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\010XPS\command]
  392. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  393.  
  394.  
  395.  
  396.  
  397.  
  398. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo]
  399. "MUIVerb"="Convert To"
  400. "Position"="Bottom"
  401. "SubCommands"=""
  402.  
  403. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell]
  404.  
  405. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\001DOC]
  406. "MUIverb"="Word document 1997-2003 (DOC)"
  407. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  408.  
  409. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\001DOC\command]
  410. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  411.  
  412. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\002DOCX]
  413. "MUIVerb"="Word document 2007-2019 (DOCX)"
  414. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  415.  
  416. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\002DOCX\command]
  417. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  418.  
  419. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\003PDF]
  420. "MUIVerb"="Portable Document Format (PDF)"
  421. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  422.  
  423. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\003PDF\command]
  424. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  425.  
  426. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\004RTF]
  427. "MUIVerb"="Rich Text Format (RTF)"
  428. "Icon"="shell32.dll,1"
  429.  
  430. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\004RTF\command]
  431. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  432.  
  433. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\005ODT]
  434. "MUIVerb"="Open Document Text (ODT)"
  435. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  436.  
  437. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\005ODT\command]
  438. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  439.  
  440. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\006TXT]
  441. "MUIVerb"="Plain Text File (TXT)"
  442. "Icon"="shell32.dll,70"
  443.  
  444. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\006TXT\command]
  445. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  446.  
  447. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\007HTM]
  448. "MUIVerb"="HTML webpage (HTM)"
  449. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  450.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  451.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  452.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  453.  35,00,00,00
  454.  
  455. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\007HTM\command]
  456. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  457.  
  458. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\008HTML]
  459. "MUIverb"="HTML webpage ()HTML)"
  460. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  461.  
  462. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\008HTML\command]
  463. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  464.  
  465. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\009XML]
  466. "MUIVerb"="XML File (XML)"
  467. "Icon"="ieframe.dll,2"
  468.  
  469. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\009XML\command]
  470. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  471.  
  472. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\010XPS]
  473. "MUIVerb"="XPS File (XPS)"
  474. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  475.  
  476. [HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\010XPS\command]
  477. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  478.  
  479.  
  480.  
  481.  
  482.  
  483. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo]
  484. "MUIVerb"="Convert To"
  485. "Position"="Bottom"
  486. "SubCommands"=""
  487.  
  488. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell]
  489.  
  490. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\001DOC]
  491. "MUIverb"="Word document 1997-2003 (DOC)"
  492. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"
  493.  
  494. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\001DOC\command]
  495. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""
  496.  
  497. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\002DOCX]
  498. "MUIVerb"="Word document 2007-2019 (DOCX)"
  499. "Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"
  500.  
  501. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\002DOCX\command]
  502. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""
  503.  
  504. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\003PDF]
  505. "MUIVerb"="Portable Document Format (PDF)"
  506. "Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"
  507.  
  508. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\003PDF\command]
  509. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""
  510.  
  511. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\004RTF]
  512. "MUIVerb"="Rich Text Format (RTF)"
  513. "Icon"="shell32.dll,1"
  514.  
  515. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\004RTF\command]
  516. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""
  517.  
  518. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\005ODT]
  519. "MUIVerb"="Open Document Text (ODT)"
  520. "Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"
  521.  
  522. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\005ODT\command]
  523. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""
  524.  
  525. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\006TXT]
  526. "MUIVerb"="Plain Text File (TXT)"
  527. "Icon"="shell32.dll,70"
  528.  
  529. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\006TXT\command]
  530. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""
  531.  
  532. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\007HTM]
  533. "MUIVerb"="HTML webpage (HTM)"
  534. "Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  535.  00,46,00,69,00,6c,00,65,00,73,00,5c,00,49,00,6e,00,74,00,65,00,72,00,6e,00,\
  536.  65,00,74,00,20,00,45,00,78,00,70,00,6c,00,6f,00,72,00,65,00,72,00,5c,00,69,\
  537.  00,65,00,78,00,70,00,6c,00,6f,00,72,00,65,00,2e,00,65,00,78,00,65,00,2c,00,\
  538.  35,00,00,00
  539.  
  540. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\007HTM\command]
  541. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""
  542.  
  543. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\008HTML]
  544. "MUIverb"="HTML webpage ()HTML)"
  545. "Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"
  546.  
  547. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\008HTML\command]
  548. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""
  549.  
  550. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\009XML]
  551. "MUIVerb"="XML File (XML)"
  552. "Icon"="ieframe.dll,2"
  553.  
  554. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\009XML\command]
  555. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""
  556.  
  557. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\010XPS]
  558. "MUIVerb"="XPS File (XPS)"
  559. "Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"
  560.  
  561. [HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\010XPS\command]
  562. @="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""
  563.  
  564. '@ | Set-Content C:\bin\wordsav.reg
  565.  
  566. regedit.exe /s C:\bin\wordsav.reg
  567. }
  568.  
  569. function Uninstall {
  570.  
  571. @'
  572. Windows Registry Editor Version 5.00
  573.  
  574. [-HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo]
  575. [-HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo]
  576. [-HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo]
  577. [-HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo]
  578. [-HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo]
  579. [-HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo]
  580.  
  581. '@ | Set-Content uninstall.reg
  582.  
  583. regedit /s uninstall.reg
  584. Remove-Item C:\bin\Word2Any.ps1
  585. Remove-Item C:\bin\wordsav.reg
  586. Remove-Item C:\bin
  587. }
  588. [Console]::WindowWidth = 192
  589. [Console]::Title = "Word2AnyInstall"
  590. @'
  591. ################################################################################################################################################################
  592.                      
  593.                                                          Word2AnyInstall.ps1
  594.   This script will install context menus on .DOC,.DOCX,.RTF,.PDF,.HTM,.HTML,.ODT,.XML,.XPS files to convert them to different format using MS Word
  595.   Right-click any file in these extensions and you will get a menu abiove "Properties" use it
  596.   An MSI-based (not Click-To-Run) installation of MS Office is required, will work for Office 2007+ versions and even Unactivated versions will work too
  597.   While conversion, just make sure that MS Word is not Open and please don't occupy C:\bin directory where files will be kept
  598.  
  599. ################################################################################################################################################################
  600.  
  601. '@
  602. $msg = @'
  603.  
  604. [1] Install
  605. [2] Repair
  606. [3] Uninstall
  607.  
  608. '@
  609. choice /c 123 /n /m $msg
  610. switch ($LastExitCode) {
  611. 1 {Install}
  612. 2 {Install}
  613. 3 {Uninstall}
  614. }
  615.  
  616. Write-Host "`nDone!"
  617. Read-Host
  618.  
  619.  
  620.  
  621.  
  622.  
  623.  
  624.  
  625.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement