Michael Sager
asked on
SCCM VBS Custom Detect file for application success
Hello all - I am trying to get a VBS to detect an existence of a file - there is a possibility that the application could be ran multiple times so I am writing the file with APPLICATION_MMDDYYYY.log format that way if it ran today it detects and thinks it is a success
as for the detect of the file I have this, but only detects APLICATION.log - how do I add creating the MMDDYYYY inside of it and then detect that file?
‘Declare needed variables
Dim FSO, File, WaitTime, TotalWaitTime
‘ Initialize constants
Const InitialTime = 30000
Const Delay = 60000
Const Timeout = 600000
‘ Set inital values
Set FSO = CreateObject (“scripting.FileSystemObje ct”)
File = “C:\temp\APPLICATION.LOG”
WaitTime = InitialTime
TotalWaitTime = 0
‘ Loop until file is found or timeout exceeded, sleeping for WaitTime between each iteration
Do While TotalWaitTime < Timeout
TotalWaitTime = TotalWaitTime + WaitTime
WScript.sleep WaitTime
If fso.fileExists (File) Then
WScript.sleep Delay
WScript.StdOut.Write “The file was detected”
WScript.Quit(0)
End If
Loop
WScript.Quit(0)
as for the detect of the file I have this, but only detects APLICATION.log - how do I add creating the MMDDYYYY inside of it and then detect that file?
‘Declare needed variables
Dim FSO, File, WaitTime, TotalWaitTime
‘ Initialize constants
Const InitialTime = 30000
Const Delay = 60000
Const Timeout = 600000
‘ Set inital values
Set FSO = CreateObject (“scripting.FileSystemObje
File = “C:\temp\APPLICATION.LOG”
WaitTime = InitialTime
TotalWaitTime = 0
‘ Loop until file is found or timeout exceeded, sleeping for WaitTime between each iteration
Do While TotalWaitTime < Timeout
TotalWaitTime = TotalWaitTime + WaitTime
WScript.sleep WaitTime
If fso.fileExists (File) Then
WScript.sleep Delay
WScript.StdOut.Write “The file was detected”
WScript.Quit(0)
End If
Loop
WScript.Quit(0)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Glad we could help.
@OP, experts and future visitors:
Please remember to endorse my, or any other expert's comments that you found helpful by clicking on the "Thumb's Up" button
Read more on endorsements
https://www.experts-exchange.com/discussions/218503/What-are-Endorsements.html
@OP, experts and future visitors:
Please remember to endorse my, or any other expert's comments that you found helpful by clicking on the "Thumb's Up" button
Read more on endorsements
https://www.experts-exchange.com/discussions/218503/What-are-Endorsements.html
ASKER