Batch file 将通配符作为附件发送

Batch file 将通配符作为附件发送,batch-file,vbscript,cmd,automation,Batch File,Vbscript,Cmd,Automation,我正在尝试执行一个批处理,它将在特定日期发送附件。 此批处理文件(Date.bat)将基于当前日期将文件复制到新文件夹: copy C:\test\output.csv C:\test2\output%date:~-4,4%_%date:~-10,2%_%date:~7,2%.csv 此电子邮件.vbs脚本将向用户发送附件: Set objMessage = CreateObject("CDO.Message") objMessage.Subject = "test123" objMessa

我正在尝试执行一个批处理,它将在特定日期发送附件。 此批处理文件(
Date.bat
)将基于当前日期将文件复制到新文件夹:

copy C:\test\output.csv C:\test2\output%date:~-4,4%_%date:~-10,2%_%date:~7,2%.csv
电子邮件.vbs
脚本将向用户发送附件:

Set objMessage = CreateObject("CDO.Message")
objMessage.Subject = "test123" 
objMessage.From = "spartan@test.com" 
objMessage.To = "test123@test.com" 
objMessage.HTMLBody = strHTML
objMessage.AddAttachment "c:\test\output.csv"

'==This section provides the configuration information for the remote SMTP server.
'==Normally you will only change the server name or IP.
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'Name or IP of Remote SMTP Server
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "spartan-dev"

'Server port (typically 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

objMessage.Configuration.Fields.Update

'==End remote SMTP server configuration section==

objMessage.Send
例如,当我在周五执行
Date.bat
时,周五的附件将在下周一发送。

使用任务调度程序

这将显示如何连接到计算机,并列出根文件夹中的任务

Set TS = CreateObject("Schedule.Service")
TS.Connect("Serenity")

Set rootFolder = TS.GetFolder("\")

Set tasks = rootFolder.GetTasks(0)

If tasks.Count = 0 Then 
    Wscript.Echo "No tasks are registered."
Else
    WScript.Echo "Number of tasks registered: " & tasks.Count

    For Each Task In Tasks
    A=Task.Name
    A = A & " " & Task.NextRunTime
    A = A & " " & Task.LastTaskResult
    wscript.echo A
    Next
End If
您还可以使用batchfile。请参见
schtasks/?

这是文件夹中列出文件的帮助

   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.GetFolder("c:\")
   Set fc = f.Files
   For Each f1 in fc
      s = s & f1.name 
   Next
   Msgbox s

问题是文件名每周都在更改。那么您对这个文件名了解多少,只知道文件夹中的文件?或者名称遵循设置的模式?outputYYYY\u MM\u DD.csv。日期每星期都在变