简体   繁体   English

NSIS简单地将一个文件从程序文件目录中的另一个文件夹复制到安装目录中

[英]NSIS simple copy one file from another folder in program files directory to installation dir not working

I tried to create an installer to install a application. 我试图创建一个安装程序来安装应用程序。 The basic stuff works fine, but I have problems, when it comes up to simply copy an existing files, which is located in some subfolder of Program Files folder. 基本的东西工作正常,但是当我想简单地复制位于Program Files文件夹的某些子文件夹中的现有文件时,我遇到了问题。 The scenario behind this, is that the application has different versions and a license file. 其背后的场景是该应用程序具有不同的版本和许可证文件。 When the app gets installed, the installer looks for an existing file, and if exists, should just copy that license file to the $INSTDIR/license folder. 安装该应用程序后,安装程序将查找现有文件,如果存在,则应将该许可证文件复制到$ INSTDIR / license文件夹中。

Example: 例:

 C:\Program Files (x86)\MyApp\Ver1.0\license\   // here's the location of old license file
 C:\Program Files (x86)\MyApp\Ver2.0\license\   // here to put the old license file

Following section is condensed to the relevant stuff: 以下部分简要介绍了相关内容:

Section "License of other Version"
IfFileExists '$PROGRAMFILES\MyApp\Ver1.0\license\some_license.slc' beginLicense endLicense
Goto endLicense
beginLicense:
  MessageBox MB_OK "We have found an old license file. Do you wanna to use it for current installation ?"
  CreateDirectory "$INSTDIR\license"
  CopyFiles "$PROGRAMFILES\MyApp\Ver1.0\license\some_license.slc" $INSTDIR/license/some_license.slc"
endLicense:
    MessageBox MB_OK "There were no license found."
SectionEnd

The compiling runs fine, but the installation process denotes an error when trying to copy the file. 编译运行良好,但是在尝试复制文件时安装过程指示错误。 But it gives no further explanation, why it failed. 但是它没有给出进一步的解释,为什么失败了。 I tried also using the File directive, but that produced other errors, because of using the constants in file directive (file not found, and that sort of errors) and even the script cannot compile. 我也尝试使用File指令,但是由于在file指令中使用了常量(未找到文件,以及此类错误),甚至还导致脚本无法编译,因此产生了其他错误。 I tried also using a macro, mentioned here in another question of stackoverflow (sry, didnt have the link anymore), but it didnt worked for me, too. 我也尝试使用一个宏,这里在另一个stackoverflow问题中提到了(很抱歉,没有链接了),但是它对我也没有用。 What am I doing wrong, is it not allowed to use constants in CopyFile directive ? 我在做什么错,在CopyFile指令中不允许使用常量吗? Any help is appreciated. 任何帮助表示赞赏。

You need to change: 您需要更改:

CopyFiles "$PROGRAMFILES\\MyApp\\Ver1.0\\license\\some_license.slc" $INSTDIR/license/some_license.slc"

To: 至:

CopyFiles "$PROGRAMFILES\\MyApp\\Ver1.0\\license\\some_license.slc" $INSTDIR\\license\\some_license.slc"

NSIS is not a fan of / slashes. NSIS不喜欢/斜杠。 While most of the low-level kernel32 functions can handle them, not all things in the shell can and that probably includes SHFileOperation used by CopyFiles . 尽管大多数低级kernel32函数可以处理它们,但外壳程序中并非所有功能都可以并且可能包括CopyFiles使用的SHFileOperation Even if that was not the case, internal path processing in NSIS tends to eat / slashes... 即使不是这种情况,NSIS中的内部路径处理也容易吃掉/斜线...

暂无
暂无

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

相关问题 将.3gp 文件从一个目录“External Dir”移动或复制到 Android 中的另一个外部目录 - Move or copy .3gp files from one directory “External Dir” to another External directory in Android 有选择地将文件从一个文件夹目录复制到另一个文件夹 - Selectively copy files from one folder directory to another 如果该文件夹不存在,如何通过创建文件夹将文件从一个目录复制到另一个目录 - How to copy a file from one directory to another directory by creating the folder if that folder does not exist 在nsis中安装时从文件读取,但不要在目标PC上将其复制 - read from a file while installation in nsis but do no copy it on the destination pc 在 php 中将文件从一个文件夹复制到另一个文件夹 - Copy a file from one folder to another in php 在SVN中的目录中搜索具有特定文件扩展名的文件,然后复制到另一个文件夹? - Search directory in SVN for files with specific file extension and copy to another folder? 如何将文件从一个目录复制到另一目录? - How to copy my files from one directory to another directory? 使用MATLAB将每5个文件中的一个文件从一个文件夹复制到另一个 - Copy one file every 5 files from a folder to another one using MATLAB 将一个文件的内容写入nsis中同一文件夹中的另一个文件 - write contents of one file to another file in the same folder in nsis 将文件从一个文件夹复制到另一个文件夹并重命名文件 - Copy files from one folder to another and rename the files
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM