Day 25: User and system scripts in Lights-Out 2
Today we will look into an experimental feature available on Windows client computers: User and system scripts which are executed if a server is available or unavailable.
User and system scripts
You can use these scripts to change your environment or run an action. User and system scripts are extension points for advanced users!
A look at user scripts
To access the template files for user scripts, go to %localappdata%\AxoNet Software GmbH\LightsOut2Client\Scripts. Enter %localappdata% in the address field of file explorer and press enter. Then navigate to AxoNet Software GmbH\LightsOut2Client\Scripts. There are two files, rename one or both to *.cmd and enter your batch commands.
These files are executed in the current user context. You can use different files for different users.
User_server_offline.cmd
This files is executed if the server goes offline.
@echo off rem ************************************************************************ rem Server is offline rem rem Rename this file to user_server_offline.cmd and add your offline rem commands here. rem rem Location: %localappdata%\AxoNet Software GmbH\LightsOut2Client\Scripts rem rem Note: This file is executed under your local user account. rem ************************************************************************ rem put your server offline command(s) here rem ...
User_server_online.cmd
This file is executed, you guessed it, if the server goes online. The template content is identical. You can run any command you like. Be careful with interactive commands, these my block execution of your script. If possible add parameters which set a default behavior, like always overwrite files, or always assume yes to a confirmation.
A look at system scripts
To access the template files for system scripts, go to “C:\Program Files\AxoNet Software GmbH\LightsOut2\scripts”. Again, there are two files, rename one or both to *.cmd and enter your batch commands.
Caveat emptor
Double check what you are doing. Verify that these files are not writeable for everybody!
System_server_offline.cmd
This file is executed if the server goes offline. For example, set the DNS server to the address of your router.
@echo off rem ************************************************************************ rem Server is offline rem rem Rename this file to system_server_offline.cmd and add your offline rem commands here. rem rem Location: %programfiles%\AxoNet Software GmbH\LightsOut2Client\Scripts rem rem Note: This file is executed under SYSTEM account. Verify that it's rem not writeable for anybody else. rem ************************************************************************ rem put your server offline command(s) here, e.g. set DNS to your router rem ...
System_server_online.cmd
This files is executed if the server goes online. The template content is identical. For example, set the DNS entry to the address of your server (if your server is doing DNS of course).
Summary
User and system scripts provide an extension point for advanced users. Use with care. Be aware that the scripts may be executed multiple times.
Tomorrow we will look at mobile access with Lights-Out Mobile.
Here you will find the complete list of all days of our step-by-step series.