Logging use of executables in Windows
This handy little tip can be used to log the use of .exe, .lnk, .pif,
.bat, and .com files on your computer. All it needs is a little registry tinkering. Place
this code in a module, and set the project startup object to 'Sub Main'
Procedure
Sub Main()
If Command$ <> "" Then
Open "c:\apps\exelog.txt" For Append As #1
Print #1, Command$ & " " & CStr(Now)
Close #1
Call Shell(Command$, vbNormalFocus)
End If
End
End Sub
Registry Changes
The registry changes are:
HKEY_CLASSES_ROOT\exefile\shell\open\command to:
"C:\exewrap.exe" "%1" %*
HKEY_CLASSES_ROOT\lnkfile\shell\open\command to: "C:\exewrap.exe" "%1"
%*
HKEY_CLASSES_ROOT\piffile\shell\open\command to: "C:\exewrap.exe" "%1"
%*
HKEY_CLASSES_ROOT\batfile\shell\open\command to: "C:\exewrap.exe" "%1"
%*
HKEY_CLASSES_ROOT\comfile\shell\open\command
to: "C:\exewrap.exe" "%1" %*
What happens it that instead of running
the program directly, Windows calls our program, which logs
filename and time, and then calls the program.
|