Vbscript msgbox 超出文件列表

Vbscript msgbox out of file list

我是 vbs 的新手,但我需要制作一个脚本,将文件从一个文件夹复制到另一个文件夹,然后读取复制文件的空列表并制作一个包含这些名称的日志文件。这就是我得到它的地方。接下来我需要做的是从这个列表中创建某种 msgbox/IEmsg。这个 msgbox 应该有所有的文件名,行下一行,刚刚复制的那个脚本。

这是我的脚本:

StrMonth = Month(Date)
 If Len(strMonth) = 1 Then
 strMonth = "0" & strMonth
 End If
 StrDay = Day(Date)
 If Len(strDay) = 1 Then
 strDay = "0" & strDay
 End If
 StrYear = Year(Date)

 FolderName = "c:\Rafel" & strDay & "." & strMonth & "." & StrYear
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET objFolder = objFSO.CreateFolder(FolderName)
 objFSO.CopyFile "c:\Rafel\files\*.*", FolderName & "\"

  Wscript.Sleep 1000
  IF objFSO.FileExists( FolderName & "\database.txt") THEN
    Wscript.Echo "Folder created, files are copied."
  END IF


SET objFSO = CreateObject("Scripting.FileSystemObject") 
FILEFOLDER = FolderName
SET objFolder = objFSO.GetFolder(FILEFOLDER)
SET filelist = objFolder.Files
FILELOG = FolderName & "\file log.log"

FOR EACH objFile IN filelist
        FILENAME = FILENAME & "###" & Now & " File copied" & "###" & vbCrlf &_
                  "    File name:" & objFile.Name & vbCrlf &_
                    "    Create date:" & objFile.DateLastModified & vbCrlf &_
                      "    Size:" & objFile.Size & vbCrlf &_
                        vbCrlf
NEXT
SET objFile = objFSO.CreateTextFile(FILELOG)
              objFile.Write vbCrlf
              objFile.Write(FILENAME) 
              objFile.Close

如您所见,它可以制作副本和创建包含文件列表的日志文件。但是我怎样才能制作一个包含这些文件列表的消息框呢?我试过了,for each 但它只是为每个文件发送“垃圾邮件”msgbox。

我是菜鸟所以请记住这一点。 :)

使用自定义 wscript.shell 弹出框来扩展消息框的最大字符数并相应地显示消息框。

More info

代码。

StrMonth = Month(Date)
 If Len(strMonth) = 1 Then
 strMonth = "0" & strMonth
 End If
 StrDay = Day(Date)
 If Len(strDay) = 1 Then
 strDay = "0" & strDay
 End If
 StrYear = Year(Date)

 FolderName = "c:\Rafel" & strDay & "." & strMonth & "." & StrYear
Set objFSO = CreateObject("Scripting.FileSystemObject")
SET objFolder = objFSO.CreateFolder(FolderName)
 objFSO.CopyFile "c:\Rafel\files\*.*", FolderName & "\"

  Wscript.Sleep 1000
  IF objFSO.FileExists( FolderName & "\database.txt") THEN
    Wscript.Echo "Folder created, files are copied."
  END IF


SET objFSO = CreateObject("Scripting.FileSystemObject") 
FILEFOLDER = FolderName
SET objFolder = objFSO.GetFolder(FILEFOLDER)
SET filelist = objFolder.Files
FILELOG = FolderName & "\file log.log"

FOR EACH objFile IN filelist
        FILENAME = FILENAME & "###" & Now & " File copied" & "###" & vbCrlf &_
                  "    File name:" & objFile.Name & vbCrlf &_
                    "    Create date:" & objFile.DateLastModified & vbCrlf &_
                      "    Size:" & objFile.Size & vbCrlf &_
                        vbCrlf
NEXT
SET objFile = objFSO.CreateTextFile(FILELOG)
              objFile.Write vbCrlf
              objFile.Write(FILENAME) 
              objFile.Close

Dim objShell : Set objShell = CreateObject("Wscript.Shell")
objShell.Popup FILENAME, 0, "Filenames", 0