【问题标题】:How to find the most recent modified file in a particular folder using nsis script?如何使用 nsis 脚本在特定文件夹中查找最近修改的文件?
【发布时间】:2016-06-22 09:06:38
【问题描述】:

是否可以在 .nsh 文件中使用 Powershell script 来执行此操作?

【问题讨论】:

  • 到目前为止你尝试过什么?一个简单的谷歌搜索会让你进入 NSIS 主页,其中包含如何从安装程序执行 powershell 脚本的示例

标签: powershell nsis


【解决方案1】:

您可以使用!system 指令调用外部应用程序。

这通常与!tempfile 和!include 结合使用,以获得外部应用程序写入的输出:

; We need a file in %temp% that the external command can write to.
!tempfile TMPINC

; This !system command tries to find the file in the Windows directory
!system `cd /D %windir% & FOR /F %A IN ('dir /A:-D /T:W /O:D /B') DO @(> "${TMPINC}" echo.!define RECENTMOD "%~fA")` 

!include "${TMPINC}"
!delfile "${TMPINC}"
!undef TMPINC
!ifndef RECENTMOD
!error "No files found!"
!endif

Section
File "${RECENTMOD}"
SectionEnd

【讨论】:

    猜你喜欢
    • 2012-06-12
    • 2011-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多