如何将错误重定向到 VBS 中的文本文件 [英] How to redirect error to a Text file in VBS

查看:22
本文介绍了如何将错误重定向到 VBS 中的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 vb 脚本将输出重定向到文本文件

How to redirect Output to a Text file using vb script

我有一个这样的代码

Dim tsIn
set tsIn = goFS.OpenTextFile("E:\..t.csv") 'if file doesn't exist then error

 If Err.Number <> 0 Then
    MsgBox Err.Description & "Input File Did not open" '> "E:\t.txt"
    Exit Sub
 End If

但是如果文件夹中不存在文件,如何重定向我得到的错误?

But how to redirect the error i get if a file doesn't exist in the folder?

我尝试了 > 但没有结果!

i tried > but there's no result!

推荐答案

将错误重定向到输出.%errorlevel% 仍然是 0.

Redirect error to output. %errorlevel% will still be 0 though.

cscript myscript.vbs > myscript.log 2>&1

这篇关于如何将错误重定向到 VBS 中的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆