如何使用 NSIS 将子目录及其内容移动到另一个目录
How to move a subdirectory with its contents to another directory with NSIS
这是我第一次使用 NSIS,我想编辑一个脚本 NSIS 以允许我:
如果是第一次安装 -> 在位置 "C:\Users\ali.ait-mouhoub.ext\AppData" 中创建目录 "Affaires"。
如果是更新(所以目录 "Affaires" 它已经存在于 "C:\N.O.E" 中)-> 将目录 "Affaires" 及其内容移动到 "C:\Users\ali.ait-mouhoub.ext\AppData"。
当前脚本在 "C:\N.O.E" 中创建目录 "Affaires"。
你能帮我修改我的脚本以满足我的需要吗?
如果新旧位置都在同一个卷上,那么您可以使用 Rename
:
Section
Rename "$InstDir\Stuff" "$InstDir\OldStuff"
SectionEnd
如果新位置可能在不同的卷上,那么您必须复制+删除:
!include LogicLib.nsh
Section
ClearErrors
CopyFiles /Silent "$InstDir\Stuff" "x:\Backup"
${If} ${Errors}
MessageBox MB_ICONSTOP "Unable to move!"
${Else}
RMDir /R "$InstDir\Stuff"
${EndIf}
SectionEnd
这是我第一次使用 NSIS,我想编辑一个脚本 NSIS 以允许我:
如果是第一次安装 -> 在位置 "C:\Users\ali.ait-mouhoub.ext\AppData" 中创建目录 "Affaires"。
如果是更新(所以目录 "Affaires" 它已经存在于 "C:\N.O.E" 中)-> 将目录 "Affaires" 及其内容移动到 "C:\Users\ali.ait-mouhoub.ext\AppData"。
当前脚本在 "C:\N.O.E" 中创建目录 "Affaires"。
你能帮我修改我的脚本以满足我的需要吗?
如果新旧位置都在同一个卷上,那么您可以使用 Rename
:
Section
Rename "$InstDir\Stuff" "$InstDir\OldStuff"
SectionEnd
如果新位置可能在不同的卷上,那么您必须复制+删除:
!include LogicLib.nsh
Section
ClearErrors
CopyFiles /Silent "$InstDir\Stuff" "x:\Backup"
${If} ${Errors}
MessageBox MB_ICONSTOP "Unable to move!"
${Else}
RMDir /R "$InstDir\Stuff"
${EndIf}
SectionEnd