AutoRun on System Events

USBDLM

 

AutoRun on System Events


 

In analogy to the AutoRun function, USBDLM can execute a command-line on system events.

 

The events are

 

OnServiceStart       Start of the USBDLM service, before checking the drive letters

OnServiceStarted     Start of the USBDLM service, after checking the drive letters

OnServiceStop        Stop of the USBDLM service

OnServiceShutdown    Shutdown of the USBDLM service (on Windows shutdown)

OnUserLogon          After user logon

OnUserLogoff         After user logoff

OnUserLock           After locking the workstation

OnUserUnlock         After unlocking the workstation

OnUserConnect        "connecting" of mouse and keyboard with the desktop (e.g. after logon or unlocking the workstation)

OnUserDisconnect     "disconnecting" of mouse and keyboard from the desktop (e.g. after logoff or locking the workstation)

OnUserActivated      After user logon, after unlocking the workstation and after switching to a user

OnUserDeactivated    After logoff, after locking the workstation and after initiating a user switch 

OnSleepRequest       On standby and hibernation; Windows does not wait for more than 2 seconds

                     No more available since Vista/Win7

OnSleep              On standby and hibernation; in real live it might be triggered on wakeup

OnResume             On wakeup from standby and hibernation

OnUndockRequest      On soft "Undock" (e.g. thru the start menu)

OnUndock             After successfully soft "Undock" (e.g. thru the start menu)

OnDock               After "Docking" but only if the "Undock" was done thru the start menu

 

OnUserConnect and OnUserDisconnect mean the connection of the input devices (mouse and keyboard) with the desktop. Under XP OnUserDisconnect is not triggered before a different user logs on, so it is not useful.

 

Under Vista and Windows 7 OnUserLock and OnUserUnlock are not triggered when switched from one user to another. Under XP they are triggered but not in the following situation: User1 is logged on, switches to the logon screen, User2 logs on, User2 logs off, User1 logs on again. Even User1 got a Lock before, XP does not trigger an Unlock.

 

Because neither Connect/Disconnect nor Lock/Unlock are reliable under XP, USBDLM generates OnUserActivated and OnUserDeactivated which are reliable.

 

For events where the user is not logged on a system=1 is required to execute the program in the "Local System" context.

 

OnSleepRequest and OnSleep does not guarantee that something is executed (and finished) before the system goes to sleep. OnSleep is often triggered in fact on wake up...

OnSleepRequest does not exist under Vista, Windows 7 and Server 2008.

 

If the Windows option "Ask for password on resume from standby" is activated then under XP the workstation gets locked on wakeup, so then events OnUserLock, OnUserDisconnect and OnUserDeactivated are triggered only then. USBDLM can lock the workstation on standby, so the event are triggered before going to sleep, but this is not reliable. Sometimes it does not work or the system stops going to sleep.

 

[Settings]

LockWorkstationOnSleep=1

 

 

The other parameters known from [OnArrival], as openstyle, system etc work here too. Furthermore multiple open lines can be defined by numbering them.

 

For events which are triggered when the user is already gone the program is executed in the System context.

 

 

Sample for creating a network drive on user logon:

 

[OnUserLogon]

open="%windir%\System32\cmd.exe" /c net user X: \\server\share /user:username password

openstyle=min

 

 

Since V4.5 multiple sections of a type can be created but the only criteria available are the user criterions and the file exists criterions.

The user criteria makes no sense in a OnUserLogoff section because it's information is already gone then.

 

 

Sample for starting the WIA service for admins and stop it for non-admins on logon:

 

[OnUserLogon]

IsUserAdmin=1

open=net start stisvc

system=1

 

[OnUserLogon]

IsUserAdmin=0

open=net stop stisvc

system=1

 

system=1 makes the NET.EXE being started in the "System" context, this ensures the console window is not seen by the user and the required privileges are available.