安装程序忽略WriteRegStr(尝试将应用程序添加到Win Startup)

gfy*_*ans 4 registry nsis windows-7

我正在安装一个应用程序到Windows 7机器(我的应用程序是针对一个特定的设备),我试图让它在操作系统启动/登录时运行.

这是一个Silverlight OOB应用程序,我认为这可能是一个问题,但我用记事本测试它仍然无法正常工作.

我按照这里的例子:

!include "MUI.nsh"

Name "Tech Drive Installer"
OutFile "techdrive_setup.exe"
InstallDir "$PROGRAMFILES\Tech Drive"

RequestExecutionLevel admin
ShowInstDetails show

!insertmacro MUI_LANGUAGE "English"

Section
    SetOutPath "$INSTDIR"
    SetOverwrite ifnewer

    File "TechDrive.xap"
    ExecWait '"$PROGRAMFILES\Microsoft Silverlight\sllauncher.exe" /install:"$INSTDIR\TechDrive.xap" /origin:"http://localhost/TechDrive.xap" /shortcut:desktop'

    WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Run\" "TechDrive" '"$PROGRAMFILES\Microsoft Silverlight\sllauncher.exe" 3388701632.localhost'
SectionEnd
Run Code Online (Sandbox Code Playgroud)

为什么这不起作用?

And*_*ers 6

WriteRegStr调用在这台32位Win7机器上运行良好.写信给HKLM时,你应该确保你是管理员.

如果您使用的是64位操作系统,则最终会写入注册表WOW64部分.在NSIS中,您可以使用SetRegView指令控制它,但Run键应该可以工作.

您可以使用Autoruns验证是否正确添加了值,或使用Process Monitor直接监视它.如果仍然无法启动,我会仔细检查路径以确保它是正确的.(启动时运行的程序也不允许需要管理员权限)