我试图在多个地方的VB脚本中使用一个变量。每次我调用变量时,都会计算这个变量。vb脚本中的时间变量
脚本是否可以使用变量的初始值?
对于实施例 -
在子StartServers的,所述DatenTime变量具有一定时间的值(例如:2014-01-16-16-10-01.50)和后120秒的睡眠时间,所述DatenTime值在子例程SendMail中添加120秒(例如:2014-01-16-16-12-01.50)导致不同的时间戳,并且不会发送附件,因为它找不到文件名。
在此先感谢您的任何答案。请让我知道是否需要更多细节。
=============================
DatenTime = "%date:~10,4%-%date:~4,2%-%date:~7,2%_%time:~0,2%_%time:~3,2%_%time:~6,5%"
Sub StartServers
wshShell.Run "E:\Automation\bin\queryhpe.cmd > E:\Automation\log\query_hpe_"&DatenTime&".log"
WScript.Sleep 120000
End Sub
Sub SendMail
On Error Resume Next
.
.
.
.
.
Set .Configuration = iConf
.To = sEmailList.ReadLine
.From = "<[email protected]>"
.Subject = "STAGE: Querying Windows Services at " & Time & " on " & Date
.Textbody = "STAGE: Querying Windows executed at " & Time & " on " & Date & " by " & sWho & "." & vbcrlf & vbcrlf & "Pls find the info on following location " & "Pls Review attached logs for detailed information"
.AddAttachment "E:\Automation\log\query_hpe_"&DatenTime&".log"
.Send
End With
Loop
End Sub