0

我有一个调用 vbs 脚本的批处理文件,如下所示:

cd d:
    cd D:\Application\Pentasafe\HKPentasafe\DailyLog\Deployment Code
    cscript CommandProcessing.vbs
    del /s "D:\Application\Pentasafe\HKPentasafe\DailyLog\Command Usage by Command\Tempworkspace\*.txt"

这个批处理文件调用这个vbs(命令处理)然后将删除临时工作区中的文件

Const ForReading = 1
Const ForWriting = 2

Dim Source, Dest

objStartFolder = "D:\Application\Pentasafe\HKPentasafe\DailyLog\Command Usage by Command\Tempworkspace"
objDestFolder = "D:\Application\Pentasafe\HKPentasafe\DailyLog\Command Usage by Command\Scripted"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files

'Only one file expected.
For Each objFile in colFiles
    Source = ObjStartFolder + "\" + objFile.Name
    Dest = ObjDestFolder + "\" + objFile.Name
    wscript.echo Source
    wscript.echo Dest
Next

Set objFile = objFSO.OpenTextFile(Source, ForReading)

Set objFile1 = objFSO.CreateTextFile(Dest, ForWriting)

Do Until objFile.AtEndOfStream
    Strline = objFile.ReadLine
    'wscript.echo Strline

    If InStr(Strline,"CHGUSRPRF") Then
    Prependtext = "CHGUSRPRF"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"STRSQL") Then
    Prependtext = "STRSQL"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"STRDFU") Then
    Prependtext = "STRDFU"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"UPDATA") Then
    Prependtext = "UPDATA"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"EZVIEW") Then
    Prependtext = "EZVIEW"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"WRKQRY") Then
    Prependtext = "WRKQRY"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline,"WRKUSRPRF") Then
    Prependtext = "WRKUSRPRF"
    wscript.echo Strline
    objFile1.WriteLine Strline
    ElseIf InStr(Strline, "             ") Then
    If (Prependtext <> "") Then
        objFile1.WriteLine Replace(Strline, "             ", Prependtext)
        wscript.echo Replace(Strline, "             ", Prependtext)
    else
        objFile1.WriteLine Strline   
    End If
    Else 
    Prependtext = ""
    objFile1.WriteLine Strline
    End If
Loop

objFile.Close
objFile1.Close

但是,当我在 Windows Server 2008 中安排此作业时,它始终不会调用 vbs 脚本。而是跳过它然后执行删除工作。我试图通过双击批处理文件手动运行它。它在window xp中运行良好,直到我们升级到window server 2008。有人对这个主题有任何想法吗?

4

2 回答 2

1

批处理文件运行时的当前驱动器是什么?很可能是C:驱动器。由于您没有将 D: 设置为当前驱动器,因此不会找到 CommandProcessing.vbs。要修复它,请将其更改为 D:CommandProcessing.vbs 或将 D: 设为当前驱动器。

于 2012-07-11T23:28:08.113 回答
0

文件 CommandProcessing.vbs 位于何处?

在 D:\Application\Pentasafe\HKPentasafe\DailyLog\Deployment 代码中?

可能 cd 命令失败,因为第一行中的路径不在 qoutes 中。然后cscript找不到脚本文件。

于 2012-07-11T07:26:11.460 回答