安装WPS后,无法在explorer预览文档

Q:

如果先安装MS Office再安装WPS,WPS会替换MS Office的预览器,但是又没有把自己的预览器dll写入注册表,导致系统无法调用。

A1:

一种解决办法是换回MS Office的预览器

修改注册表HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers\

把数据为“Microsoft Word Previewer”的名称记住,如果数值为“Microsoft Word 预览器”则修改为“Microsoft Word Previewer”。

然后找到HKEY_CLASSES_ROOT\.doc\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}和HKEY_CLASSES_ROOT\.docx\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f},将其中默认项的数据修改为之前记下的名称。

Excel文件和PPT文件同理。

常见的MSOffice三个预览器ID:

"{84F66100-FF7C-4fb4-B0C0-02CD7FB668FE}"="Microsoft Word previewer"

"{65235197-874B-4A07-BDC5-E65EA825B718}"="Microsoft PowerPoint previewer"

"{00020827-0000-0000-C000-000000000046}"="Microsoft Excel previewer"

A2:

另一种,WPS其实有做预览器功能,但是只有企业版的安装包能正确写入注册表,个人版好像目前还有问题。以下是企业版的预览器注册表信息(未测试)。

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0C7FEF07-DCD9-4120-9647-D1CE32F289CD}]
@="WPS文字 预览器"
"DisplayName"="WPS文字 预览器"
"DisableLowILProcessIsolation"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0C7FEF07-DCD9-4120-9647-D1CE32F289CD}\InprocHandler32]
@="ole32.dll"

;注意修改路径
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0C7FEF07-DCD9-4120-9647-D1CE32F289CD}\LocalServer32]
@="\"C:\\Program Files\\Kingsoft\\WPS Office\\11.8.2.12119\\office6\\wps.exe\" /Preview"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{A1BBCFD9-B54C-443D-BC56-0BC3840120DB}]
@="WPS演示 预览器"
"DisplayName"="WPS演示 预览器"
"DisableLowILProcessIsolation"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{A1BBCFD9-B54C-443D-BC56-0BC3840120DB}\InprocHandler32]
@="ole32.dll"

;注意修改路径
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{A1BBCFD9-B54C-443D-BC56-0BC3840120DB}\LocalServer32]
@="\"C:\\Program Files\\Kingsoft\\WPS Office\\11.8.2.12119\\office6\\wpp.exe\" /Preview"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{E260F96C-8EF4-4C24-A2B9-455F1D116531}]
@="WPS表格 预览器"
"DisplayName"="WPS表格 预览器"
"DisableLowILProcessIsolation"=dword:00000001

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{E260F96C-8EF4-4C24-A2B9-455F1D116531}\InprocHandler32]
@="ole32.dll"

;注意修改路径
[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{E260F96C-8EF4-4C24-A2B9-455F1D116531}\LocalServer32]
@="\"C:\\Program Files\\Kingsoft\\WPS Office\\11.8.2.12119\\office6\\et.exe\" /Preview"

可以使用powershell脚本添加相关注册表项,使用管理员运行:


#requires -RunAsAdministrator
$ErrorActionPreference = "Stop"

# WPS组件配置
$wpsComponents = @(
    @{ Name = "WPS文字"; CLSID = "{0C7FEF07-DCD9-4120-9647-D1CE32F289CD}"; ExeName = "wps.exe" },
    @{ Name = "WPS表格"; CLSID = "{E260F96C-8EF4-4C24-A2B9-455F1D116531}"; ExeName = "et.exe" },
    @{ Name = "WPS演示"; CLSID = "{A1BBCFD9-B54C-443D-BC56-0BC3840120DB}"; ExeName = "wpp.exe" }
)

# 检测最新WPS安装路径
function Get-LatestWPSPath {
    $searchPaths = @(
        "${env:ProgramFiles(x86)}\Kingsoft\WPS Office",
        "${env:ProgramFiles}\Kingsoft\WPS Office",
        "${env:LOCALAPPDATA}\Kingsoft\WPS Office"
    )

    $latestVersion = $null
    $installPath = $null

    foreach ($basePath in $searchPaths) {
        if (Test-Path $basePath) {
            # 获取所有版本号目录并按版本排序
            $versionDirs = Get-ChildItem -Path $basePath -Directory | 
                          Where-Object { $_.Name -match '^\d+\.\d+\.\d+\.\d+$' } |
                          Sort-Object { [version]$_.Name } -Descending

            if ($versionDirs) {
                $latestDir = $versionDirs[0].FullName
                $office6Path = Join-Path $latestDir "office6"
                
                if (Test-Path $office6Path) {
                    return $office6Path
                }
            }
        }
    }
    
    throw "未检测到WPS Office安装路径,请确认已安装WPS"
}

# 创建注册表项函数
function Set-PreviewHandler {
    param($clsid, $name, $exePath)
    
    # 注册全局预览处理器
    $previewKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\PreviewHandlers"
    if (-not (Test-Path $previewKey)) {
        New-Item -Path $previewKey -Force | Out-Null
    }
    Set-ItemProperty -Path $previewKey -Name $clsid -Value $name -Type String

    # 创建CLSID配置
    $clsidKey = "Registry::HKEY_CLASSES_ROOT\CLSID\$clsid"
    if (-not (Test-Path $clsidKey)) {     
    New-Item -Path $clsidKey -Force | Out-Null
    }

    Set-ItemProperty -Path $clsidKey -Name "(Default)" -Value $name -Type String
    Set-ItemProperty -Path $clsidKey -Name "DisplayName" -Value $name -Type String
    Set-ItemProperty -Path $clsidKey -Name "DisableLowILProcessIsolation" -Value 1 -Type DWord

    # InprocHandler32
    New-Item -Path "$clsidKey\InprocHandler32" -Force | Out-Null
    Set-ItemProperty -Path "$clsidKey\InprocHandler32" -Name "(Default)" -Value "ole32.dll" -Type String

    # LocalServer32
    New-Item -Path "$clsidKey\LocalServer32" -Force | Out-Null
    Set-ItemProperty -Path "$clsidKey\LocalServer32" -Name "(Default)" -Value "`"$exePath`" /Preview" -Type String
}

# 主执行流程
try {
    $office6Path = Get-LatestWPSPath
    Write-Host "检测到WPS安装路径: $office6Path" -ForegroundColor Cyan

    foreach ($component in $wpsComponents) {
        $exePath = Join-Path $office6Path $component.ExeName
        if (-not (Test-Path $exePath)) {
            Write-Warning "未找到$($component.Name)可执行文件: $exePath"
            continue
        }
        
        Set-PreviewHandler -clsid $component.CLSID -name $component.Name -exePath $exePath
        Write-Host "已注册$($component.Name)预览处理器" -ForegroundColor Green
    }
 
    Write-Host "WPS预览处理器注册完成!请重启文件资源管理器(explorer.exe)生效。" -ForegroundColor Cyan
}
catch {
    Write-Host "发生错误: $_" -ForegroundColor Red
    exit 1
}


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wanttolearn

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值