2014-07-17 3 views
0

오류 코드 800A0409, 줄 바꿈되지 않은 문자열 상수, 아래 코드와 54.VBScript 오류 코드 800A0409, 줄 1의 끝나지 않은 문자열 상수

Option Explicit 

Dim ObjProgressMsg 
Dim fso,objText,strVstup,strVystup,f,dtmVyt,dtmF,dDiff,fName,fExt,fShort,dtmAkt,tx,msgText 
Dim strMessage,strWindowTitle,strTemp,wshShell,objTempMessage,strTempVBS 


Set fso = CreateObject("Scripting.FileSystemObject") 
Set objText = fso.GetFile("l:\bat\posledni.den") 
strVstup = "l:\filefolder\" 
strVystup = "l:\backup" 

dtmVyt = objText.DateLastModified 

msgText = "Some text about copying and renaming" & VbCrLf & "files, please wait..." 

ProgressMsg msgText 

For Each f In fso.GetFolder(strVstup).Files 

    dtmF = f.DateLastModified 

    dDiff = DateDiff("s", dtmF, dtmVyt) 

    If dDiff < 0 Then 
      ProgressMsg "" 
      WScript.Echo f 
    End If 

Next 

WScript.Echo "Some text about the task being finished." 




Function ProgressMsg(strMessage) 
' Written by Denis St-Pierre 
' Displays a progress message box that the originating script can kill in both 2k and XP 
' If StrMessage is blank, take down previous progress message box 
' Using 4096 in Msgbox below makes the progress message float on top of things 
' CAVEAT: You must have Dim ObjProgressMsg at the top of your script for this to work as described 
    Set wshShell = WScript.CreateObject("WScript.Shell") 
    strTEMP = wshShell.ExpandEnvironmentStrings("%TEMP%") 
    If strMessage = "" Then 
     ' Disable Error Checking in case objProgressMsg doesn't exists yet 
     On Error Resume Next 
     ' Kill ProgressMsg 
     objProgressMsg.Terminate() 
     ' Re-enable Error Checking 
     On Error Goto 0 
     Exit Function 
    End If 
     strTempVBS = strTEMP + "\" & "Message.vbs"  'Control File for reboot 

    ' Create Message.vbs, True=overwrite 
    Set objTempMessage = fso.CreateTextFile(strTempVBS, True) 
    objTempMessage.WriteLine("MsgBox""" & strMessage & """, 4096, """ & "a_sp_rano" & """") 
    objTempMessage.Close 

    ' Disable Error Checking in case objProgressMsg doesn't exists yet 
    On Error Resume Next 
    ' Kills the Previous ProgressMsg 
    objProgressMsg.Terminate() 
    ' Re-enable Error Checking 
    On Error Goto 0 

    ' Trigger objProgressMsg and keep an object on it 
    Set objProgressMsg = WshShell.Exec("%windir%\system32\wscript.exe " & strTempVBS) 

End Function 

posledni.den 파일의 마지막 수정 날짜보다 새로운 파일을 검색하는 동안 스크립트에 msgbox가 표시되어야합니다. 그런 다음 파일을 찾으면 msgbox를 닫고 찾은 파일을 반향시켜야합니다. 나는이 변경하는 경우 그것은 잘 작동이에

msgText = "Some text about copying and renaming" & VbCrLf & "files, please wait..." 

을 : VbCrLf의

msgText = "Some text about copying and renaming" & "files, please wait..." 

제거는 더 줄 바꿈이 분명히 발생되지 않으며, 해당 오류를 수정하는 것 같다. 나는 그것이 왜 그렇게 행동하는지 알 수 없다. 내가 뭘 잘못하고 있는지. 문제에 대한 모든 종류의 통찰력은 많이 감사 할 것입니다.

미리 감사드립니다. :)

답변

1

생성 된 .vbs의 실행에 오류가 발생합니다. 당신이 할 것은 :

>> msg1 = "A" & vbCrLf & "B" 
>> code = "MsgBox """ & msg1 & """" 
>> WScript.Echo code 
>> 
MsgBox "A 
B" 
>> Execute code 
>> 
Error Number:  1033 
Error Description: Unterminated string constant 

당신은 어떻게해야하나요 :

>> msg1 = """A"" & vbCrLf & ""B""" 
>> WScript.Echo msg1 
>> 
"A" & vbCrLf & "B" 
>> code = "MsgBox " & msg1 & ", 4096" 
>> WScript.Echo code 
>> 
MsgBox "A" & vbCrLf & "B", 4096 
>> Execute code 
>> 
>> <-- no news are good news; message displayed 
+0

완벽한, 지금 그것을 볼 수 있습니다. 이 겹 따옴표는 쌓여있을 때마다 항상 혼란 스럽습니다. 고마워요! :) – Aisling

관련 문제