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)
SCCM

Avatar of undefined
Last Comment
Shaun Vermaak

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Shaun Vermaak

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Michael Sager

ASKER
Thanks!
Shaun Vermaak

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
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck