【问题标题】:How can I use the following script?如何使用以下脚本?
【发布时间】:2021-10-25 18:26:33
【问题描述】:

我想从默认文件夹中删除除书签文件之外的所有文件。但是下面的代码不起作用。我知道我应该使用批处理文件,但是有没有办法使用下面的代码?感谢您的帮助

ExecWait '"$SYSDIR\cmd.exe" /c "SET "sourcedir=$LOCALAPPDATA\Google\Default" & SET "keepfile=Bookmarks" & FOR %a IN ("%sourcedir%*") DO IF / i NOT "%~nxa"=="%keepfile%" DEL "%a""'

【问题讨论】:

  • 您将其标记为 NSIS,但您的问题是关于批处理语法?为什么不直接在 NSIS 中编写代码呢?

标签: nsis


【解决方案1】:
Section "Prepare example"
SetOutPath "$LOCALAPPDATA\Google\Default"
SetOverwrite off
File "/oname=$outdir\Bookmarks" "${__FILE__}"
File "/oname=$outdir\Blah" "${__FILE__}"
File "/oname=$outdir\Footmarks" "${__FILE__}"
SectionEnd

!include LogicLib.nsh

Section

StrCpy $2 "$LOCALAPPDATA\Google\Default"
FindFirst $0 $1 "$2\*"
loop:
    StrCmp $1 "" done
    StrCmp $1 . next
    StrCmp $1 .. next
    ${If} $1 != "Bookmarks"
        Delete "$2\$1"
    ${EndIf}
next:
    FindNext $0 $1
    Goto loop
done:
FindClose $0

SectionEnd

【讨论】:

  • 你真是个天才。正是我想要的。它完美地工作。非常感谢
  • 你应该把它标记为答案然后......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-13
  • 1970-01-01
  • 2021-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-27
相关资源
最近更新 更多