I am creating a script to find a certain file and execute a set of commands running on Windows Server Standard SP2. I have used wildcards "?" for the time stamp in the past. The problem is that I am having problems calling the "?". Here is the code I have so far:
Option Explicit
'Date Function Declared
Function padDate(intNumber)
if intNumber <= 9 Then
padDate = "0" & CStr(intNumber)
Else
padDate = CStr(intNumber)
End If
End Function
Dim strDate
'Variable Proc for the date
strDate = Year(Date) & padDate(Month(Date)) & padDate(Day(Date))
'Set Dimension
DIM fso
'Set Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Create Condition
If (fso.FileExists("\\Server\StartOfFileName"_
& strDate & "??????_Report1.txt")) Then
'Alert User
WScript.Echo("File exists!")
WScript.Quit()
Else
'Alert User
WScript.Echo("File does not exist!")
End If
'Exit Script
WScript.Quit()
I need to find a way to get the ?????? to pose as characters no matter what. I have thought about trying a loop between 0000001 and 235959, but I thought that would take a bit.
Is there another way to declare variables within Windows?
Option Explicit
'Date Function Declared
Function padDate(intNumber)
if intNumber <= 9 Then
padDate = "0" & CStr(intNumber)
Else
padDate = CStr(intNumber)
End If
End Function
Dim strDate
'Variable Proc for the date
strDate = Year(Date) & padDate(Month(Date)) & padDate(Day(Date))
'Set Dimension
DIM fso
'Set Object
Set fso = CreateObject("Scripting.FileSystemObject")
'Create Condition
If (fso.FileExists("\\Server\StartOfFileName"_
& strDate & "??????_Report1.txt")) Then
'Alert User
WScript.Echo("File exists!")
WScript.Quit()
Else
'Alert User
WScript.Echo("File does not exist!")
End If
'Exit Script
WScript.Quit()
I need to find a way to get the ?????? to pose as characters no matter what. I have thought about trying a loop between 0000001 and 235959, but I thought that would take a bit.
Is there another way to declare variables within Windows?