为什么这个 VBScript 给我一个错误? [英] Why does this VBScript give me an error?

查看:33
本文介绍了为什么这个 VBScript 给我一个错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将此 VBScript 脚本作为 c:\test.vbs:

I saved this VBScript script to my local machine as c:\test.vbs:

WScript.StdOut.WriteLine "This is a test"

当我从命令行运行它时,出现此错误:

When I run it from the command line, I get this error:

---------------------------
Windows Script Host
---------------------------
Script: C:\test.vbs
Line:   1
Char:   1
Error:  The handle is invalid. 
Code:   80070006
Source:     (null)

---------------------------
OK   
---------------------------

我在 Windows Vista (SP1) 和 Windows XP Pro (SP3) 下得到了这个.

I get this under Windows Vista (SP1) and Windows XP Pro (SP3).

推荐答案

此链接可能对您有所帮助:

This link may help you:

http://www.tech-archive.net/Archive/Scripting/microsoft.public.scripting.vbscript/2004-07/0979.html

似乎句柄 StdOut 仅在使用控制台主机 (cscript.exe) 而不是窗口主机 (wscript.exe) 时可用代码>).如果你想让代码工作,你必须使用 cscript.exe 来运行它.

It appears that the handle StdOut is only available when using a console host (cscript.exe) and not a windowed host (wscript.exe). If you want the code to work, you have to use cscript.exe to run it.

这篇文章还描述了如何更改默认行为以使用 cscript 而不是 wscript 运行脚本.

The post also describes how to change default behavior to run scripts with cscript and not wscript.

这篇关于为什么这个 VBScript 给我一个错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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