0

我有一个在 sqlite 文件(纯文本)中搜索字符串的 VBscript。它由我的 NSIS 安装程序运行以确定安装参数。

当我从命令行运行脚本时,它一切都按计划工作,并在文件中找到它正在寻找的字符串。但是当我突然从 nsis 安装程序中通过 ExecWait 运行它时,它说它再也找不到字符串了。它并没有说它无法打开文件或任何其他错误,它只是返回该字符串不存在。

这是 nsis 脚本中的 exec:

ExecWait `"$SYSDIR\wscript.exe" "$PLUGINSDIR\myscript.vbs" "success" "failure" "done" "1"` $2

这是给我带来这么多麻烦的块:

Function LookforValue(strFile)
    iStatus = 0
    Done = false
    Const ForReading = 1

    MsgBox(S_PATTERN)
    MsgBox(F_PATTERN)   
    MsgBox(D_PATTERN)       

    Set objFSO = CreateObject("Scripting.FileSystemObject")

    objFile = 0
    Set objFile = objFSO.OpenTextFile(strFile, ForReading)
        Do Until objFile.AtEndOfStream
            strSearchString = objFile.ReadLine
            colMatchesS = InStr(strSearchString,S_PATTERN)
            colMatchesF = InStr(strSearchString,F_PATTERN)
            colMatchesD = InStr(strSearchString,D_PATTERN)

            If colMatchesS > 0 Then
                iStatus = 2
                exit do
            End If

            If colMatchesF > 0 Then
                iStatus = 3
                exit do
            End If

            If colMatchesD > 0 Then
                iStatus = 4
                exit do
            End If

        Loop
    objFile.Close



    LookforValue = iStatus

结束功能

仅供参考,我使用的是 VBscript 而不是 nsis 命令,因为 nsis 对文件被另一个进程锁定感到很挑剔。

4

1 回答 1

0

I didn't really solve the problem but i concluded it was because i was trying to use OpenTextFile on a binary file that just coincidentally didn't want to work when the other script was running it.

于 2012-07-31T00:24:57.720 回答