Ever wonder how one could use a VB Script to Time-Bomb a ThinApp package? Well, awhile back this was discussed in the Scripting Within ThinApp session of the ThinApp Bootcamp Series! Here’s how it’s done!
Basically, the way the script works is by looking at the ThinApp data container date/time stamp and comparing it to the date/time of the system. While this is not infallible, it does give Administrators some control as this would essentially force a user to need the ability to change their system time.
Expiration checks are only done during initial launch of the ThinApp Packaged app containing this script. Once the application is running, this will not continue checking nor terminate the already running ThinApp.
Additionally, while some date mod detections do exist in the script, users with abilities to change the date on their system will have the ability to circumvent this by simply setting the date to something within the valid period between the modification date and the number of days the package is valid.
Lastly, the script does not accommodate for time zone differences. If you set a ThinApp package to expire one a specific date and you change your system’s time zone to match your locale, if the update to the time zone forces you to jump to or past the expiration date then the ThinApp package will stop working by design.
ThinApp Time Bomb Script.txt – RIGHT CLICK and SAVE AS.
AdminScriptEditor Script Conversion
Dim WSHNetwork, WSHShell, objFSO, objShell, objWMIService, strComputer
Dim TSOrigin, TSCurProcName, TSSourcePath
Dim GCPOrigin, GCPLastSlash, GCPSourcePath, GCPCurProcName
Dim SandboxParent, SandboxName, SandboxPath
Dim strFilePropDateCreated, strFilePropDateModified
Dim strSelfDestruct, strFileAgeLimit, strFileWarning
strComputer = "."
Set WSHNetwork = CreateObject("WScript.Network")
Set WSHShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("Shell.Application")
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
strFileAgeLimit = 10 strFileWarning = 5
TSOrigin = GetEnvironmentVariable("TS_ORIGIN")
TSLastSlash = InStrRev(TSOrigin, "\")
TSSourcePath = Left(TSOrigin, TSLastSlash)
TSCurProcName = Mid(TSOrigin, TSLastSlash + 1, Len(TSOrigin))
GCPOrigin = GetCurrentProcessName
GCPLastSlash = InStrRev(GCPOrigin, "\")
GCPSourcePath = Left(GCPOrigin, GCPLastSlash)
GCPCurProcName = Mid(GCPOrigin, GCPLastSlash + 1, Len(GCPOrigin))
SandboxParent = GetBuildOption("SandboxPath")
SandboxName = GetBuildOption("SandboxName")
If SandboxParent = "." Then
SandboxPath = SourcePath & SandboxName
SandboxPath = SandboxParent & Chr(92) & SandboxName
If objFSO.FileExists(TSOrigin) Then
Set objFile = objFSO.GetFile(TSOrigin) strFilePropDateCreated = objFile.DateCreated strFilePropDateModified = objFile.DateLastModified strCurrentDateTime = Now strFileAge = DateDiff("d", strFilePropDateModified, strCurrentDateTime)
If strFileAge > strFileAgeLimit Then MsgBox "The application '" & GCPCurProcName & "' has reached 'End-of-Life' and will be terminated!",, "Application End of Life!"
ExitProcess 0 Else
If strFileAge < 0 Then MsgBox "The file '" & GCPCurProcName & "' has a date newer than the current system date!" & vbCrLf & vbCrLf & "This is an indication attempts are being made to circumvent the End-of-Life feature!! This application will be terminated!",, "Application End of Life Circumvention Detected!"
ExitProcess 0 End If
If (strFileAgeLimit - strFileAge) < strFileWarning Then
MsgBox "This ThinApp Packaged application will expire in " & (strFileAgeLimit - strFileAge) & " days!" & vbCrLf & vbCrLf & "Please contact this ThinApp Package Administrator for a newer version and assistance!",, "Application End of Life Near!"
Else MsgBox "The file '" & GCPCurProcName & "' could not be found!" & vbCrLf & vbCrLf & "The application will be terminated!",, "FILE NOT FOUND!"
ExitProcess 0 End If