2012-07-11 80 views
0

任務調度我有叫vbs腳本如下的批處理文件:在Win 2008將不會運行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(commandprocessing)thenit將刪除tempworkspace文件

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 

但是,當我安排在窗口服務器2008年這個工作..它總是不會調用vbs腳本。而是跳過它然後做刪除工作。 我嘗試通過雙擊批處理文件手動運行它.. 它運行良好的窗口XP直到我們升級到窗口服務器2008.任何人有任何想法在這個話題?

回答

0

CommandProcessing.vbs文件位於何處?

在D:\ Application \ Pentasafe \ HKPentasafe \ DailyLog \ Deployment Code?

可能是cd命令失敗,因爲第一行中的路徑不在qoutes中。然後cscript找不到腳本文件。

+0

感謝指出..該vbs文件是在.bat文件,爲什麼我沒有把路徑名稱相同的目錄。 – cheeseng 2012-07-11 07:51:16

1

批處理文件運行時的當前驅動器是什麼?最有可能的是C:驅動器。由於您沒有將D:設置爲當前驅動器,因此將找不到CommandProcessing.vbs。要修復它,請將其更改爲D:CommandProcessing.vbs或使D:當前驅動器。

+0

感謝它的工作! – cheeseng 2012-07-12 01:21:40

+0

很高興工作。接受答案將是一件好事,並且會讓人們更有可能在未來回答你的問題。 – 2012-07-12 01:45:14