Link to home
Start Free TrialLog in
Avatar of Michael Sager
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.FileSystemObject”)
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
Avatar of Shaun Vermaak
Shaun Vermaak
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Michael Sager
Michael Sager

ASKER

Thanks!
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