使用 NSIS 安装程序从快捷方式 "start in" 属性 中删除 \x86
Remove \x86 from Shortcut "start in" property with NSIS Installer
我正在使用 NSIS 安装程序生成 link。从桌面快捷方式启动时,我的程序无法正常运行。所以我通过右键单击桌面创建了另一个快捷方式。该计划奏效了。区别在于 NSIS 生成的快捷方式 属性“开始于”有 c:\MyProgram\x86。 Windows 生成的快捷方式 属性 “Start In”刚好有 c:\MyProgram。有没有办法从 NSIS 安装程序中设置 属性“开始于”以排除 \x86?
这是生成快捷方式的行:
; include library for system DLL's:
!include Library.nsh
; The name of the installer
Name "Example22.00"
; The file to write
OutFile "Example Setup 22.00.exe"
; The default installation directory
InstallDir "c:\test22\"
; Pages
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "test (required)"
SectionIn RO
SetOutPath "c:\test22\"
; Put file there
;File /oname=Example.exe "c:\Example22BuildFiles\program\Example.exe"
file "c:\Example22BuildFiles\program\Example.exe"
file "c:\Example22BuildFiles\program\Beep1.wav"
file "c:\Example22BuildFiles\program\Alarm.wav"
file "c:\Example22BuildFiles\program\Example.Application"
file "c:\Example22BuildFiles\program\Example.exe.config"
file "c:\Example22BuildFiles\program\Example.exe.manifest"
file "c:\Example22BuildFiles\program\System.Data.SQLite.dll"
file "c:\Example22BuildFiles\program\System.Data.SQLite.xml"
file "c:\Example22BuildFiles\icon\icon.ico"
SetOutPath "c:\test22\x64\"
file "c:\Example22BuildFiles\program\x64\SQLite.Interop.dll"
SetOutPath "c:\test22\x86\"
file "c:\Example22BuildFiles\program\x86\SQLite.Interop.dll"
WriteUninstaller "uninstall.exe"
;Create Example Folder
CreateDirectory c:\Example
CreateShortCut "$desktop\ExampleCSV.lnk" "c:\Example" 0
CreateShortCut "$desktop\Example.lnk" "c:\test22\Example.exe" "" "c:\test22\icon.ico"
SectionEnd
首先,如果您的应用程序依赖于将工作目录(“开始于”)设置为与 .exe 相同的文件夹,则它已损坏。如果用户使用“打开方式”或从终端调用您的应用程序,则工作目录可以是任何内容。除了作为命令行参数传递的文件名之外,不要在您的应用程序中 read/load 任何与 .\
相关的内容。
为什么您的快捷方式工作目录以 \x86 结尾?因为你要求它!
来自 CreateShortcut 文档:
$OUTDIR is stored as the shortcut's working directory property. You can change it by using SetOutPath before creating the shortcut or use /NoWorkingDir if you don't need to set the working directory property.
根据您的示例 $OUTDIR 由 SetOutPath "c:\test22\x86\"
设置。要为快捷方式设置特定目录,请在 CreateShortcut
.
之前使用 SetOutPath
我正在使用 NSIS 安装程序生成 link。从桌面快捷方式启动时,我的程序无法正常运行。所以我通过右键单击桌面创建了另一个快捷方式。该计划奏效了。区别在于 NSIS 生成的快捷方式 属性“开始于”有 c:\MyProgram\x86。 Windows 生成的快捷方式 属性 “Start In”刚好有 c:\MyProgram。有没有办法从 NSIS 安装程序中设置 属性“开始于”以排除 \x86? 这是生成快捷方式的行:
; include library for system DLL's:
!include Library.nsh
; The name of the installer
Name "Example22.00"
; The file to write
OutFile "Example Setup 22.00.exe"
; The default installation directory
InstallDir "c:\test22\"
; Pages
UninstPage uninstConfirm
UninstPage instfiles
;--------------------------------
; The stuff to install
Section "test (required)"
SectionIn RO
SetOutPath "c:\test22\"
; Put file there
;File /oname=Example.exe "c:\Example22BuildFiles\program\Example.exe"
file "c:\Example22BuildFiles\program\Example.exe"
file "c:\Example22BuildFiles\program\Beep1.wav"
file "c:\Example22BuildFiles\program\Alarm.wav"
file "c:\Example22BuildFiles\program\Example.Application"
file "c:\Example22BuildFiles\program\Example.exe.config"
file "c:\Example22BuildFiles\program\Example.exe.manifest"
file "c:\Example22BuildFiles\program\System.Data.SQLite.dll"
file "c:\Example22BuildFiles\program\System.Data.SQLite.xml"
file "c:\Example22BuildFiles\icon\icon.ico"
SetOutPath "c:\test22\x64\"
file "c:\Example22BuildFiles\program\x64\SQLite.Interop.dll"
SetOutPath "c:\test22\x86\"
file "c:\Example22BuildFiles\program\x86\SQLite.Interop.dll"
WriteUninstaller "uninstall.exe"
;Create Example Folder
CreateDirectory c:\Example
CreateShortCut "$desktop\ExampleCSV.lnk" "c:\Example" 0
CreateShortCut "$desktop\Example.lnk" "c:\test22\Example.exe" "" "c:\test22\icon.ico"
SectionEnd
首先,如果您的应用程序依赖于将工作目录(“开始于”)设置为与 .exe 相同的文件夹,则它已损坏。如果用户使用“打开方式”或从终端调用您的应用程序,则工作目录可以是任何内容。除了作为命令行参数传递的文件名之外,不要在您的应用程序中 read/load 任何与 .\
相关的内容。
为什么您的快捷方式工作目录以 \x86 结尾?因为你要求它!
来自 CreateShortcut 文档:
$OUTDIR is stored as the shortcut's working directory property. You can change it by using SetOutPath before creating the shortcut or use /NoWorkingDir if you don't need to set the working directory property.
根据您的示例 $OUTDIR 由 SetOutPath "c:\test22\x86\"
设置。要为快捷方式设置特定目录,请在 CreateShortcut
.
SetOutPath