如何将 RTF 文件转换为 PDF

如何将 RTF 文件转换为 PDF

希望将简单的 RTF 文件转换为 PDF。

有没有不用第三方软件的方法可以做到这一点?

答案1

我将在 Windows-Wordpad 中打开 RTF,然后使用“打印为 PDF 文件”打印机驱动程序打印为 PDF。

写字板和打印为 PDF

这将创建一个 PDF 文件,但不进行任何实际打印

答案2

如果您的 PC 上安装了 MS Word,您可以使用它将 rtf 文件保存为 pdf,方法是使用“另存为”,然后选择 PDF。将根据 rtf 文档创建一个 pdf 文档。

答案3

感谢用户红砾石谁帮助我得出这个答案。我会花一点时间让这个答案更加方便用户使用。

因此,要轻松地将 RTF 文件转换为 PDF,我们只需在 Windows-Wordpad 中打开该文件,然后单击左上角文件菜单中的打印选项:

在此处输入图片描述

接下来,选择“打印到文件”选项,然后选择“Microsoft Print to PDF”(您可能必须使用滚动条导航到左侧)笔记:这实际上并不需要打印机。它只是保存一个文件。

在此处输入图片描述

点击对话框底部的“应用”,然后点击“打印”。另一个窗口会弹出,询问您要将文件保存在哪里,同时让您选择重命名。

答案4

仅供分享,我编写了一个 powershell 脚本,它将安装右键单击上下文菜单,以将文档 (.doc、.docx、.rtf、.odt、.pdf) 转换为一键转换为其他格式。(需要基于 Microsoft Office MSI 的安装,2007+,也适用于未激活的版本)。执行脚本并单击安装以获取它们。然后右键单击 RTF 文档,将鼠标悬停在底部的转换为上,然后单击 PDF。它将出现在当前位置。使用 MS office 2013 和 2007 测试:

# Word2AnyInstall.ps1
#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
#   Right-click any file in these extensions and you will get a menu abiove "Properties" use it
#   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
#   While conversion, just make sure that MS Word is not Open and please don't occupy C:\bin directory where files will be kept

$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
if( -not ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)))
{
    Write-Host "Running Admin Shell, Please wait....."
    Start-Sleep -Seconds 1
    Start-Process powershell.exe -ArgumentList "-ExecutionPolicy Bypass -File `"$($MyInvocation.MyCommand.Path)`"" -Verb RunAs
    Exit 0
}

function Install {
If (!(Test-Path C:\bin)){
  New-Item C:\bin -Type Directory
}

@'
Param(
    [System.IO.Fileinfo]$Source,
    [String]$Format
)
$arrFileExt = @{
     "doc"      =   0
     "docx"     =   0
     "htm"      =   8   
     "html"     =   8
     "odt"      =   23
     "pdf"      =   17  
     "rtf"      =   6
     "txt"      =   4
     "xml"      =   19
     "xps"      =   18
}
$myFileType = $arrFileExt."$Format"
$myFileName = $Source.Basename
$myFileExt = "." + $Format
$toSave = Split-Path "$Source"
$myOutputFile = $toSave + "\" + $myFileName + $myFileExt
$objWord = New-Object -COMObject "Word.Application" 
$objWord.Visible = $False
$objWord.Documents.Open([string]$Source) | Out-Null
$objDoc = $objWord.ActiveDocument
$objDoc.SaveAs("$myOutputFile",$myFileType) | Out-Null
$objDoc.Close() | Out-Null
'@ | Set-Content C:\bin\Word2Any.ps1

@'
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""






[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""









[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""




[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""





[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""





[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo]
"MUIVerb"="Convert To"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell]

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\001DOC]
"MUIverb"="Word document 1997-2003 (DOC)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe,-2"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\001DOC\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"doc\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\002DOCX]
"MUIVerb"="Word document 2007-2019 (DOCX)"
"Icon"="%ProgramFiles%\\Microsoft Office\\Office15\\WINWORD.exe"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\002DOCX\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"docx\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\003PDF]
"MUIVerb"="Portable Document Format (PDF)"
"Icon"="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe,13"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\003PDF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"pdf\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\004RTF]
"MUIVerb"="Rich Text Format (RTF)"
"Icon"="shell32.dll,1"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\004RTF\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"rtf\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\005ODT]
"MUIVerb"="Open Document Text (ODT)"
"Icon"="C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe,3"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\005ODT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"odt\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\006TXT]
"MUIVerb"="Plain Text File (TXT)"
"Icon"="shell32.dll,70"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\006TXT\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"txt\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\007HTM]
"MUIVerb"="HTML webpage (HTM)"
"Icon"=hex(2):43,00,3a,00,5c,00,50,00,72,00,6f,00,67,00,72,00,61,00,6d,00,20,\
  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,\
  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,\
  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,\
  35,00,00,00

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\007HTM\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"htm\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\008HTML]
"MUIverb"="HTML webpage ()HTML)"
"Icon"="C:\\Program Files\\Internet Explorer\\iexplore.exe,17"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\008HTML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"html\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\009XML]
"MUIVerb"="XML File (XML)"
"Icon"="ieframe.dll,2"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\009XML\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xml\""

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\010XPS]
"MUIVerb"="XPS File (XPS)"
"Icon"="D:\\Windows\\System32\\xpsrchvw.exe,2"

[HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo\shell\010XPS\command]
@="powershell.exe -file C:\\bin\\Word2Any.ps1 \"%1\" \"xps\""

'@ | Set-Content C:\bin\wordsav.reg

regedit.exe /s C:\bin\wordsav.reg
}

function Uninstall {

@'
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\Word.Document.12\shell\ConvertTo]
[-HKEY_CLASSES_ROOT\Word.Document.8\shell\ConvertTo]
[-HKEY_CLASSES_ROOT\Word.RTF.8\shell\ConvertTo]
[-HKEY_CLASSES_ROOT\Word.OpenDocumentText.12\shell\ConvertTo]
[-HKEY_CLASSES_ROOT\MSEdgePDF\shell\ConvertTo]
[-HKEY_CLASSES_ROOT\MSEdgeHTM\shell\ConvertTo]

'@ | Set-Content uninstall.reg

regedit /s uninstall.reg
Remove-Item C:\bin\Word2Any.ps1
Remove-Item C:\bin\wordsav.reg
Remove-Item C:\bin
}
[Console]::WindowWidth = 192
[Console]::Title = "Word2AnyInstall"
@'
################################################################################################################################################################
                       
                                                          Word2AnyInstall.ps1
   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
   Right-click any file in these extensions and you will get a menu abiove "Properties" use it
   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
   While conversion, just make sure that MS Word is not Open and please don't occupy C:\bin directory where files will be kept

################################################################################################################################################################

'@
$msg = @'

[1] Install
[2] Repair
[3] Uninstall

'@
choice /c 123 /n /m $msg
switch ($LastExitCode) {
1 {Install}
2 {Install}
3 {Uninstall}
}

Write-Host "`nDone!"
Read-Host

相关内容