简体   繁体   English

在NSIS安装程序中使用安装程序名称重命名文件?

[英]rename file with the name of installer name in NSIS installer?

I'm working with NSIS installer. 我正在使用NSIS安装程序。 I need to change file defined in install path to the same installer name. 我需要将安装路径中定义的文件更改为相同的安装程序名称。

I try to use rename function like: 我尝试使用重命名功能:

Rename "$INSTDIR\app.exe" "$INSTDIR\installname.exe"

but I need the installer name automatic. 但我需要自动安装程序名称。

Take a look at the constants , $EXEFILE is the filename, or $EXEPATH for the full path. 看一下常量$EXEFILE是文件名,或者$EXEPATH表示完整路径。 If you want the name attribute you used in your source file, it is $(^Name) ... 如果你想要你在源文件中使用的name属性,那就是$(^Name) ......

From FileFunc header you can combine GetExeName and GetFileName macros to get the installer's name: FileFunc标头,您可以组合GetExeNameGetFileName来获取安装程序的名称:

!include "FileFunc.nsh"
OutFile test.exe

section main

    ${GetExeName} $R0
    ${GetFileName} "$R0" $R1

    MessageBox MB_OK "My installer's exe is $R1"
sectionend

Now you can test it yourself. 现在你可以自己测试一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM