意外删除了 Nullsoft 脚本中的“.exe”文件关联?

意外删除了 Nullsoft 脚本中的“.exe”文件关联?

我意外地更改了 `.exe 文件与以下 Nullsoft 脚本的关联(由VB转换器

# MyProg-Standard.nsi installation script
# Automatically generated by VB6Converter by David Nuttall
# VB6Converter was compiled on 15/02/08
#

Name "MyProg-Standard-Setup"
OutFile "MyProg-Standard-Setup.exe"
RequestExecutionLevel admin
SetCompress auto
SetCompressor /SOLID /FINAL Lzma
WindowIcon on
AutoCloseWindow false
SetDatablockOptimize on
CRCCheck on
InstProgressFlags smooth
SetDateSave on
AllowSkipFiles on
SetOverwrite IfNewer
InstallDir "$ProgramFiles\MyProg"

!include Library.nsh

Page Directory
Page Components
Page InstFiles

Var ALREADY_INSTALLED
Var Version

Section "MyProg-Standard"
    SectionIn 1 RO
    ;LogSet on  # Needs special build of NSIS to actually work.
    # Change the registry structure to reflect the directory structure you are using.
    ReadRegDWord $Version HKLM "Software\VBGenerator\MyProg-Standard" Version
    IfErrors new_installation
    StrCpy $ALREADY_INSTALLED 1
    new_installation:

    SetOutPath "$InstDir"
    File /a "Support\license.txt"
    !insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\mesa.dll" "$SysDir\mesa.dll" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\cwui.ocx" "$SysDir\cwui.ocx" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\MSWINSCK.OCX" "$SysDir\MSWINSCK.OCX" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\cwanalysis.ocx" "$SysDir\cwanalysis.ocx" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\comct332.ocx" "$SysDir\comct332.ocx" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\MSCOMM32.OCX" "$SysDir\MSCOMM32.OCX" "$SysDir"
    !insertmacro InstallLib DLL NOTSHARED REBOOT_PROTECTED \
        "Support\RICHED32.DLL" "$SysDir\RICHED32.DLL" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\RICHTX32.OCX" "$SysDir\RICHTX32.OCX" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\mscomct2.ocx" "$SysDir\mscomct2.ocx" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\MSCOMCTL.OCX" "$SysDir\MSCOMCTL.OCX" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\comdlg32.ocx" "$SysDir\comdlg32.ocx" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\TABCTL32.OCX" "$SysDir\TABCTL32.OCX" "$SysDir"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\USB_DLL.dll" "$SysDir\USB_DLL.dll" "$SysDir"
    SetOutPath "$InstDir"
    File /a "Support\MyProg_NXPUSB.exe"

    # Put shortcuts in the start menu
    CreateDirectory "$SMPrograms\MyProg"
    CreateShortCut "$SMPrograms\MyProg\MyProg.lnk" "$InstDir\MyProg_NXPUSB.exe"
    WriteRegDWord HKLM "Software\VBGenerator\MyProg-Standard" Version 1
    WriteUninstaller "$InstDir\uninstaller.exe"
    CreateShortCut "$SMPrograms\Uninstall MyProg-Standard.lnk" "C:\svn\projects\Standard_MyProg_NXPUSB\GUI\REV_M_Hardware\SWD0015-XXX\Package (3)\uninstaller.exe"
    # Set file extension to open the program.
    WriteRegStr HKCR ".exe" "" "MyProg-Standard file"
    WriteRegStr HKCR "MyProg-Standard file" "" "MyProg-Standard Document"
    WriteRegStr HKCR "MyProg-Standard file\DefaultIcon" "" "$InstDir\MyProg_NXPUSB.exe,1"
    WriteRegStr HKCR "MyProg-Standard file\shell\open\" "" "&Open"
    WriteRegStr HKCR "MyProg-Standard file\shell\open\command" "" '"$InstDir\MyProg_NXPUSB.exe" "$$1"'
    # Add uninstaller information to registry.
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProg-Standard" "DisplayName" "MyProg-Standard"
    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProg-Standard" "UninstallString" '"$InstDir\uninstaller.exe"'
    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProg-Standard" "NoModify" 1
    WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyProg-Standard" "NoRepair" 1
SectionEnd

Section Uninstall
    # Remove file extension to open the program.
    DeleteRegKey HKCR ".exe"
    DeleteRegKey HKCR "MyProg-Standard file"
    Delete /RebootOk "$SMPrograms\MyProg\MyProg.lnk"
    UnRegDLL "$InstDir\MyProg_NXPUSB.exe"
    Delete /RebootOk "$InstDir\MyProg_NXPUSB.exe"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\USB_DLL.dll"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\TABCTL32.OCX"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\comdlg32.ocx"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\MSCOMCTL.OCX"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\mscomct2.ocx"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\RICHTX32.OCX"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\RICHED32.DLL"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\MSCOMM32.OCX"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\comct332.ocx"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\cwanalysis.ocx"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\MSWINSCK.OCX"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\cwui.ocx"
    !insertmacro UnInstallLib REGDLL SHARED REBOOT_PROTECTED "$SysDir\mesa.dll"
    Delete /RebootOk "$InstDir\license.txt"
    Delete /RebootOk "$SMPrograms\\Uninstall .lnk"
    RMDir "$SMPrograms\"
    DeleteRegKey HKLM "Software\VBGenerator\MyProg-Standard"
    SetOutPath "\"  ;Change to root directory to allow the next step to succeed.
    RmDir /RebootOk "$INSTDIR"
SectionEnd

Section "-Install VB6 runtimes"
    ;Add code here that sets $ALREADY_INSTALLED to a non-zero value if"
    ;the application is already installed. For example:

    IfFileExists "C:\svn\projects\Standard_MyProg_NXPUSB\GUI\REV_M_Hardware\SWD0015-XXX\Package (3)\MyProg-Standard.nsi.exe" 0 new_installation2
    StrCpy $ALREADY_INSTALLED 1
    new_installation2:

    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED \
        "Support\msvbvm60.dll" "$SYSDIR\msvbvm60.dll" "$SYSDIR"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\oleaut32.dll" "$SYSDIR\oleaut32.dll" "$SYSDIR"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\olepro32.dll" "$SYSDIR\olepro32.dll" "$SYSDIR"
    !insertmacro InstallLib REGDLL $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\comcat.dll"   "$SYSDIR\comcat.dll"   "$SYSDIR"
    !insertmacro InstallLib DLL    $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\asycfilt.dll" "$SYSDIR\asycfilt.dll" "$SYSDIR"
    !insertmacro InstallLib TLB    $ALREADY_INSTALLED REBOOT_PROTECTED \
        "Support\stdole2.tlb"  "$SYSDIR\stdole2.tlb"  "$SYSDIR"
SectionEnd

Section "-un.Uninstall VB6 runtimes"
    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\msvbvm60.dll"
    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\oleaut32.dll"
    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\olepro32.dll"
    !insertmacro UnInstallLib REGDLL SHARED NOREMOVE "$SYSDIR\comcat.dll"
    !insertmacro UnInstallLib DLL    SHARED NOREMOVE "$SYSDIR\asycfilt.dll"
    !insertmacro UnInstallLib TLB    SHARED NOREMOVE "$SYSDIR\stdole2.tlb"
SectionEnd

我猜我做的是,当 VB Converter 工具提示文件关联时,我只是把 .exe 粘在那里,并没有真正理解它在要求什么(特别是因为我的程序没有文件关联),这就是结果。我猜罪魁祸首是以下几行:

# Remove file extension to open the program.
    DeleteRegKey HKCR ".exe"
    DeleteRegKey HKCR "MyProg-Standard file"
    Delete /RebootOk "$SMPrograms\MyProg\MyProg.lnk"

话虽如此,我尝试了以下解决方案。

  • 我尝试过解决方案此处介绍但似乎没有任何效果。
  • 我尝试了几种解决方案这里也一样。EthanAD 的解决方案对我也没什么用。不过,assoc .exe=exefile在一台电脑上运行确实有效(我测试安装的那台电脑)。但它在编译 NSIS 脚本和运行我的开发环境的电脑上不起作用。在那台电脑上,为了解决这个问题,我相信我为了.exe急于解决问题而选择了记事本作为打开文件的默认程序。现在,每个程序都用记事本打开(我甚至用记事本打开了记事本本身)。assoc .exe=exe在那台电脑上运行没有效果,即使运行assoc .exe和分别ftype exefile返回正确的结果(.exe=exefileexefile="%1" %*)。

有人能帮助我恢复与 EXE 文件相关的 Windows 默认功能吗?

- - 编辑 - -

需要澄清的是,这不是这个问题,我已经尝试过(作为管理员),但没有任何效果。

相关内容