我有一个调用 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。有人对这个主题有任何想法吗?