'Citrix XenApp and Presentation Server application launch logging (works with legacy farms) 'Written by Jason Samuel - jasonsamuel.com Dim WshShell, oExec, myDateString, mytimestring Set WshShell = CreateObject("WScript.Shell") 'the getpubapp.exe tool launches Set oExec = WshShell.Exec("\\fileserver\CitrixPS4Launches\getpubapp.exe") 'wait for the process to execute and end Do While oExec.Status = 0 WScript.Sleep 100 Loop 'initialize the variable that the app name output will go to MyAppName="" 'scan and append the command output flow to MyAppName Do While oExec.StdOut.AtEndOfStream <> True MyAppName = MyAppName + oExec.StdOut.ReadLine Loop 'MyAppName is now populated with the output of getpubapp.exe 'set the date and time into variables myDateString = Date() mytimestring = Time() 'setup to write the file output Const ForReading = 1, ForWriting = 2, ForAppending = 8 Set objNetwork = CreateObject("Wscript.Network") Dim fso, f Set fso = CreateObject("Scripting.FileSystemObject") 'file share location where we're going to write the text file to (make sure all users have permission to write here) Set f = fso.OpenTextFile("\\fileserver\CitrixPS4Launches\PS4launches.txt", ForAppending, True) 'writes the data to the txt file f.Write myDateString & " " & mytimestring & " " & MyAppName & " " & wshShell.ExpandEnvironmentStrings( "%userdomain%/%username% %COMPUTERNAME% %SESSIONNAME% %CLIENTNAME%" ) & vbCrLf f.Close