Nicolas Van Wijnsberghe, a colleague of mine, sent me this great example of just how flexible ThinApp and its VB-Script support is. With our VB-Script your imagination is pretty much the limitation..
Here is a VB-Script that will provide a poor mans software-metering solution.
This example uses a network share stored cvs file to register each users usage of an application. You can later use the cvs and Excel to create nice looking tables of usages. If the network share is not accessible will the script display an error message but will continue to execute the packaged application. You could add all kind of logic to the script, e.g. kill the application if we cannot access the network path or why not use a database instead of writing to a cvs file.
This is an example of what the cvs file will look like and some generated graphs.
Simply create a file in the root of your project named anything but with the extension of .vbs and copy the below script into it. Please remember to change the niopath= to fit your environment and make sure the end users have permissions to create and modify the file. This is important since the vb-script is executing in the end users content.
Dim sDst, fso, fLOut, sComputer, sUser, sNow
Dim WshShell, objEnv
‘Path to csv file on share accessible by all users in domain
Set WshShell = CreateObject("WScript.Shell")
Set objEnv = WshShell.Environment("Process")
sComputer = objEnv("COMPUTERNAME")
sUser = objEnv("USERNAME")
sNow = Now
Set fso = CreateObject("Scripting.FileSystemObject")
' Check if path to csv file is correct and accessible, if not throws warning
if fso.FileExists(niopath) then
‘Open file from share
Set fLOut = fso.OpenTextFile(niopath, 8,True)
‘Write new line in csv comma delimited: format computernname,username,datetime
sDst = sComputer& "," & sUser & "," & sNow & vbCrLf
‘Clear objects in memory and exit
Set fLOut = Nothing
Set fso = Nothing
Msgbox "Sorry, This Application is started without correct Network Access" & vbNewLine & vbNewLine _
& "=> Please Contact your Application Administrator at extension 007" , vbWarning, "Warning"