小编Ber*_*rtB的帖子

当变量是参数时,VBS脚本没有输出,但在变量是硬编码时正确输出

这很奇怪:当textFile是硬编码时,双击[输出(拆分)弧文件]运行时脚本运行正常.将文件拖放到脚本上时,没有错误,也没有输出文件.使用拖放时脚本肯定会运行,我在writeTo之前的行中添加了一个简单的消息框,以确认它确实达到了这一点.拖放时没有文件输出,只有当textFile被硬编码时才能正常工作.有人请帮忙!

if WScript.Arguments.Count <> 0 then

    textFile = WScript.Arguments(0)

else

    textFile = "multi2.txt"

end if


saveTo = ""
writeTo = ""
strNewLine = "%_N_"
headingPattern = "(%_N_)"

dim fileFrom, regex, fileTo
Set fso = CreateObject("Scripting.FileSystemObject")

set fileFrom = fso.OpenTextFile(textFile)
set regex = new RegExp
set fileTo = nothing


with regex
    .Pattern = headingPattern
    .IgnoreCase = false
    .Global = true
end with

while fileFrom.AtEndOfStream <> true
    line = fileFrom.ReadLine
    set matches = regex.Execute(line)
    if matches.Count > 0 then

        strCheckForString = UCase("%") …
Run Code Online (Sandbox Code Playgroud)

vbscript arguments drag-and-drop

0
推荐指数
1
解决办法
98
查看次数

标签 统计

arguments ×1

drag-and-drop ×1

vbscript ×1