Vbscript cmd中的WScript.Echo输出命令

Vbscript cmd中的WScript.Echo输出命令,vbscript,Vbscript,我需要一些帮助来输出CMD中的错误 我们的时间表系统无法将假期添加到用户时间表中,这是通过脚本完成的。下面是有问题的脚本部分 sql = "select h_user,h_date1,h_hrs,h_approved,hol_default from holidays,hol_type,logins_users where userid=h_user and h_type=hol_id and h_date1='" & today & "' order by h_type

我需要一些帮助来输出CMD中的错误

我们的时间表系统无法将假期添加到用户时间表中,这是通过脚本完成的。下面是有问题的脚本部分

    sql = "select h_user,h_date1,h_hrs,h_approved,hol_default from holidays,hol_type,logins_users where userid=h_user and h_type=hol_id and h_date1='" & today & "' order by h_type desc"
    'WScript.Echo Sql

    ar.Open Sql, cnn ', adOpenForwardOnly, adLockReadOnly, adCmdText

    If Not (ar.EOF And ar.BOF) Then  'found some holidays
        ar.movefirst()
        While Not ar.EOF
            count = count + 1
            user = ar.Fields("h_user").Value
            datestr = ar.Fields("h_date1").Value
            hours = ar.Fields("h_hrs").Value
            approved = ar.Fields("h_approved").Value
            defaulthours = ar.Fields("hol_default").Value
            If hours = 8 Then actualhours = defaulthours
            If hours = 4 Then actualhours = defaulthours / 2
            If hours = 0 Then actualhours = 0

            sqlstr = "select * from timesheets where ts_user=" & user & " and ts_hrs in(" & hours & "," & defaulthours &") and ts_date='" & today & "' and ts_job=20"
            ar1.Open sqlstr, cnn
            If Not (ar1.EOF And ar1.BOF) Then
                'record exists
                sqlstr = "update timesheets set ts_eduser=0,ts_eddate=now() where ts_user=" & user & " and ts_hrs=" & actualhours & " and ts_date='" & today & "' and ts_job=20"
            Else
                'no record
                sqlstr = "insert into timesheets (ts_user,ts_date,ts_hrs,ts_approved,ts_job,ts_cruser,ts_crdate) values (" & user & ",'" & today & "'," & actualhours & "," & approved & ",20,0,Now())"
            End If
            ar1.Close()
            cnn.Execute("insert into tracking (t_user,t_query) values (0,'" & addslashes(sqlstr) & "')")
            cnn.Execute(sqlstr)
            ar.MoveNext()
        Wend
    End If
    ar.Close
Next
message = message & count & " holidays entries added" & vbCrLf
count = 0

Set ar1 = Nothing
Set ar2 = Nothing
Set ar1 = CreateObject("ADODB.RecordSet")
Set ar2 = CreateObject("ADODB.RecordSet")

For n = 0 To 28
    daystr = DateAdd("d", n, Now())

    today = Mid(daystr, 7, 4) & "-" & Mid(daystr, 4, 2) & "-" & Left(daystr, 2)
我需要做的是在cmd窗口中专门输出defaulthours的结果,以允许我检查它检索的数据中的错误

我意识到这是一个
WScript.Echo
命令,但我尝试了几种变体,它阻止了脚本运行


有人能给我指出正确的方向吗?

cscript.exe
而不是默认的解释器(
wscript.exe
)运行脚本

cscript.exe
WScript.Echo
消息打印到控制台,而不是显示消息弹出窗口


或者,您可以将
WScript.Echo
替换为
WScript.StdOut.WriteLine
,这将需要
cscript
,否则会引发错误(因为
WScript.StdOut
WScript
中不可用)。

谢谢您的回复,我正在通过命令行运行cscript中的脚本,目前得到的结果如下:C:\JARS_auto.vbs(178,65)Microsoft VBScript运行时错误:类型不匹配我需要实际获取该数据,所以我可以在myphpadmin中找到记录并删除/修改它。@CarlHeath这是一个与您在问题中发布的完全不同的问题。请将您的代码缩减为仍然暴露问题的代码,然后用该代码和代码生成的错误消息发布一个新问题。我通过在第178行上方添加wscript.echo defaulthours行找到了我要寻找的答案,现在它输出了它试图除以2的数据。只是试着在后端追踪记录并修改它。
cscript //NoLogo C:\path\to\your.vbs