Lock and Load is an application that allows you to listen to various windows events, and execute an arbitrary number of commands (or scripts) as a response.
Lock and Load is written using C# and requires the .NET 3.5 framework.
Upon execution Lock and Load immediately goes to the Notification Area (aka System Tray) where it remains waiting to respond to any configured events.
Download
The latest version can be found here Lock and Load - Version 1.2.1
Configuration
Upon first execution an empty configuration item will be placed in your Application Folder (this depends upon the version of windows being used), in a sub folder named “notunusual\LockAndLoad”.
Beginning with version 1.2.1 you can now override the location of the configuration file
Command Line Arguments
| Switch | Argument | Note |
|---|---|---|
| -c | path_to_executeable | The full path to the configuration file to load |
The configuration looks like the following –
<ConfigurationManager
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ExecuteItemsArray>
<Executable
FileName="C:\Path\To\My\App.exe"
Arguments=""
Trigger="SessionLock"
UseShellExecute="false"
WaitToFinish="false"
CreateWindow="false" />
</ExecuteItemsArray>
<InteractiveMode>true</InteractiveMode>
</ConfigurationManager>
The InteractiveMode tag is a Boolean value (true/false) if true a notification icon will be created to interact with Lock and Load. This value defaults to true.
You can provide any number of Executable elements that re-act to any of the trigger events.
Executable Attributes
| Attribtue | Description |
|---|---|
| FileName | String – The full path to the application to execute |
| Arguments | String – Any arguments to pass to the executable, this can contain any of the special paramaters |
| UseShellExecute | Can be true or false – Indicates whether to use the operating system shell to start the process. |
| WaitToFinish | Can be true or false – Should Lock and Load wait until the executable is finished before moving on to the next executable? |
| CreateWindow | Can be true or false – Indicates whether to start the process in a new window |
| Trigger | See Triggerable Events Table |
Triggerable Events Table
| Name | Description |
|---|---|
| ConsoleConnect | A session has been connected from the console. |
| ConsoleDisconnect | A session has been disconnected from the console. |
| RemoteConnect | A session has been connected from a remote connection. |
| RemoteDisconnect | A session has been disconnected from a remote connection. |
| SessionLogon | A user has logged on to a session. |
| SessionLogoff | A user has logged off from a session. |
| SessionLock | A session has been locked. |
| SessionUnlock | A session has been unlocked. |
| SessionRemoteControl | A session has changed its status to or from remote controlled mode. |
Special Parameters Table
| Name | Description |
|---|---|
| %trigger% | This is replaced with the trigger name which initiatied this event, the values passed match the Trigger names |
| %user% | This is replaced with the currently active windows user |
| %date% | This is replaced with the current date and time with “Short Date/Long Time”, equivalent to passing ‘G’ as the date time format specifier |
| %date-X% | This is replaced with the current date and time in a format specifed with X. The possible values for X are described in the MSDN Standard Date and Time Format Strings page. |

How would we pull the logged in user’s username into the arguements? For instance, we might want to pass the username to a URL via CURL.
thanks
At this point there’s no way to do that, I’ll begin to look into setting up some variables that could be used.
In the mean time, you could always have it call a shell script, or another executable, which would then be able to access what you need, and then make that call curl with your variables.
Version 1.1 now has this ability to log the username, what triggered the lock and the date/time stamp of the event, hopefully this works for you.
Would it be possible to get an option / commandline switch to suppress the notification area icon? I’m deploying this preconfigured under VMware ThinApp, and would like to restrict my users ability to interact with it.
I’ll add in an option to do that and put an updated version out.
I’ve updated Lock and Load to version 1.2 and added an option to disable the notification are icon, please let me know if this works/doesn’t work out for you; Thanks for the feedback!
Very cool, thx for the app.
Question: It appears the app runs under the local user account, correct? Will it run under the system account properly? I ask because I have a program that takes a picture with my webcam any time the program is run and saves it to a file. I want that file to be in a folder that only admins can access, but cannot do that unless the application runs with system rights, and it won’t run with system rights unless the app that launches it already has system rights… I’m creating a way to photograph any user logging into my pc
I’ll look into this, but I don’t see any reason why it wouldn’t run under the system account. Give me a few days and I’ll see what I find, if you figure it out, please let me know.
Ok just looked into running things under the system account, and everything seems ok. When I ran it, it puts the configuration settings here –
c:\Windows\System32\config\systemprofile\AppData\Roaming\notunusual\LockAndLoad\
I also made sure and set interactive mode to false in the configuration file, and things seemed to work without a hitch.
Please let me know if you run into any issues.
Hi,
This program seems to be exactly what I need because windows scheduler doesn’t seems to allow executing scripts when locking or unlocking.
However I ran into problems:
I configured the configuration.xml to run a .vbs file on sessionlock and unlock, but nothing happens. There is no logging.xml created either.
LockAndLoad is in the windows tray.
Active items – 0
Am I doing something wrong?
Thnx!
The logging feature isn’t actually implemented right now, can you copy/paste your configuration.xml file to see if anything jumps out at me as being incorrect?
Hi, Thx for you reply,
Here’s my configuration file,
I tried several combinations and parameters.
I’m running windows7 btw.
C:\Users\username\AppData\Roaming\notunusual\LockAndLoad\logging.xml
true
Here without html-entities:
<ConfigurationManager xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ExecuteItemsArray>
<Executable
FileName="U:\Activity\lock.vbs"
Arguments=""
Trigger="SessionLock"
UseShellExecute="true"
WaitToFinish="false"
CreateWindow="false" />
<Executable
FileName="U:\Activity\unlock.vbs"
Arguments=""
Trigger="SessionUnLock"
UseShellExecute="true"
WaitToFinish="false"
CreateWindow="false" />
<Executable
FileName="U:\Activity\unlock.vbs"
Arguments=""
Trigger="ConsoleConnect"
UseShellExecute="false"
WaitToFinish="false"
CreateWindow="false" />
<Executable
FileName="U:\Activity\lock.vbs"
Arguments=""
Trigger="ConsoleDisconnect"
UseShellExecute="false"
WaitToFinish="false"
CreateWindow="false" />
</ExecuteItemsArray>
<LoggingPath>C:\Users\username\AppData\Roaming\notunusual\LockAndLoad\logging.xml</LoggingPath>
<InteractiveMode>true</InteractiveMode>
</ConfigurationManager>
I figured out what it is in the trigger line for the second executable you have “Trigger=”SessionUnLock”", the parser is being very strict when matching it up to the valid triggers, it should be SessionUnlock (no uppercase L).
I’ll fix things so it’s less strict with the parsing of the arguments and does a better job reporting errors like this, but if you change that it should load fine.
Thanks for getting me the information back and sorry for the trouble.
Hi!
Thanks for Lock and Load — it does what i need. But it will be great if I could pass path to configuration as a parameter.
I’m starting Lock and Load at user logon through domain group policies, but currently i’m forced to copy configuration file to every user machine, which is inconvenient.
Thanks.
I’ll look into adding this soon.
So basically you want a command line configuration option that lets you point to the configuration file?
Yes. That would be enough for my purposes.
I’ve added this feature and released a new version 1.2.1.
Please let me know if this works for you.
HI guys,
I’ve found an issue, for computers who use windows XP, i’ve got an error : DW20.exe which is the error reporting for windows when i shut down computers
I’ve fixed it by setting in the configuration.xml in sessionlogoff a batch file who kill LockAndLoad.exe before the system because i’ve tried to shut down when lockandload wasnt started as a process and i didnt have any error messages.
However, do you have any fix for that ?
Regards,
genepix
Have you tried this in anything other then XP? (I don’t have XP here to try it with).
Also what events do you have setup? Session Logoff?
Hi,
very useful too, thanks for it!
Two questions though:
1. I’ve set-up all possible triggers and try to fire Session Lock/Unlock Logon/Logoff. Lock/Unlock works fine whilst for Logon/Logoff it seems that nothing happens. Any special consideration for these events that I should pay attention to? Specially for logon I cannot fully understand how this event can be captured as long as the earliest moment when you can start the application is in logon script which I assume is triggered after SessionLogon event.
2. The issue reported by genpix related to XP is valid in my environement as well. Any advice on how to deal with it?
Many thanks!
I’ll have to look into #1, I’m guessing I’m going to need to get the program to run as a service, and you’d then run it as a system service that isn’t tied directly to a user (because as you note can’t really be running to catch a logon even while you’re logging on).
As for #2, i’m going to need to try and get a copy of XP, perhaps through a virtual machine to look into this.
Thanks for the feedback.
Hi
any news on #1?
I suspect it will take time for you to implement the program as a service for successful logon event capture.
But what’s the problem with logoff? – I seem not to be able to capture it – likewise philip.
otherwise – really good piece of sw
Yeah sorry I haven’t had much time to get to switching the tool over to being a service, it’s on my to do list.
I’m not sure about logoff, I’ll look into that as well.
Hi
any good prospects of it coming any time?
still waiting for that new version
Sorry I’ve been really busy with my normal work so haven’t gotten a chance to convert the program to a service.
However the logon/logoff are suffering from the same obvious flaw; if we’re running the application as a user we have a chicken/egg problem.
Just wanted to give you an update on this.
I was able to get the tool running as a service, but ran into a problem I’m going to have to see if I can get around.
When the service is started as a local system account, it doesn’t end up getting notified at all of any of the events, which seem to be tied to the account that is running, and as a local system, you as a user logging in and out does nothing.
I’m going to look into a few other things to see if I can’t get it working.
It also seems incredibly strange to me that there are events you can listen to, but ultimately can’t ever really be notified of them due to logical issues with logging on/off.
Hi,
I am trying to use the %trigger% and %user% variables but they never resolve. Could you help me figure out what I am doing wrong. Below is my configuration script and the script it is calling upon a trigger.
true
C:\Users\TGlenn\AppData\Roaming\notunusual\LockAndLoad\logging.xml
Script—————————–
echo %trigger% %date% %time% %user% >> \\server\Logs\Computer\test.log
The configuration.xml did show the whole configuration.
true
C:\Users\TGlenn\AppData\Roaming\notunusual\LockAndLoad\logging.xml
Here is a trimmed down version of my configuration.xml since pasting isn’t working. Also, has the logging be implemented yet? It doesn’t seem to create a log at all.
false
C:\User\TGlenn\AppData\Roaming\notunusa\LockAdnLoad\logging.xml
Logging isn’t implemented yet.
The %trigger% (and other) commands are evaluated when used in the argument field of the structure.
For example I tested this out (the xml has been removed due to the comment software stripping things out).
FileName=”cmd.exe”
Arguments=”/k echo %trigger% %date% %user% >> test.log”
Trigger=”RemoteDisconnect”
UseShellExecute=”true”
WaitToFinish=”true”
CreateWindow=”true”
This generated the following –
RemoteDisconnect 2/21/2013 6:23:22 PM cobijones\Phillip
Let me know if that helps you out until I get some time to add logging.