HookApplication introduction – hope so you will like it :)

Hey hey!

 Right now I am finishing version 0.00….1 of HookApplication. This is tiny utility that could be (hope so) quite powerfull in fact.

It allows you to hook to different applications and change their behavior based on file name (calc.exe for example) – right now I got 3 scenarios supported:

  • Disable application – if someone try to run application, it wont start, instead msgbox is presented (or nothing, depends on your choice). If you (for whatever reason) dont want to use Software Restriction, this is scripted way how to perform it. This is just “by the way” feature.

  • Replace application – this allows you to redirect application to another one. For example you can replace taskmgr with Process Explorer (I know this is not best example, because Process Explorer supports this by default), I am using this for replacing Notepad with Crimson Editor, Calc with PowerCalc (or what the heck is the name…) etc.

  • Custom actions – here are many oportunities and it depends on your imagination. You can create custom list of actions. Example for monitoring solitair usage:

    • Create entry in log file (StarterPlaying, Username, date, time) when user started application

    • Start main application, wait until it finished

    • When he closes it, create entry in log file (FinishedPlaying, Username, date, time)

 There are many ways how you could use it… Right now I got few scripts linked with it and I am testing, for example I got application (lets say Accounting.exe) and we have only 5 licenses. I got custom actions linked with this executable, that means that whenever you run it, it will first check if there are less than 5 instances running and then it will allow you to run it.

 Linking with application is based on process name, therefore if you run this application from cmd, shortcut, double-clicking on icon, it doesnt matter.

Next week I would like to publish some preview version, if any one of you got some space where to host it, let me know.

 Also I would REALLY appreciate if you could write some comments – features you would like to request, questions etc, it will help me a lot if I could think about these questions before application is finished.


Here is example screen from Hook application manager:

Preview of HookApplication

Switch to systray with keyboard shortcut


Many people including me prefer to use keyboard instead of mouse, however sometimes you must switch :( One of common reasons is when you want to do something that involves systray menu (bottom right) – however there is one trick how to avoid it – if you hit Winkey + B, systray is focused – try it, maybe you will find it useful as I do :)

Introduction to batch services


This blog post is going to be interesting mostly for people that got already a lot of experiences with batch scripting.


I am going to talk about quite interesting stuff I call batch services – I love this technology and it saved me and helped me many times in all my previous projects.


Batch service is in fact quite simple – it is just batch, that got actions linked to different folders and it is running periodically.


In my current job, we are using batch services for automatic rebooting of servers and for sending mails, however it was extremely useful for deployment because you were able to do a lot of stuff with very simple scripts.


Consider scenario where you want to allow your technicians to unlock some accounts for example without giving them permissions.


You write script called UnlockAccountEngine.cmd. This script will consist of following lines:


For /f “usebackq delims=. tokens=1,*” %%i IN (`Dir /s /b “\\server\UnlockAccounts$\Account.*”`) Do (

Echo %Date%;%Time%;%UserDomain%;%%j>>”\\Server\UnlockAccounts$\Unlock.log

Net User %UseDomain%\%%j /Domain /Active:Yes



Extremely simple, right? What it means is that it will unlock every account when file Account.UserName is available. For example if I would like to unlock my account, I will just create file Account.Mzugec.


Now we will create client script call UnlockAccount.cmd


This file contains following lines:

@Echo off

Set /p Int.AccountName=Please specify account name which you would like to unlock:

If Exist \\Server\UnlockAccounts$\Account.%Int.AccountName% (

Echo WARNING: Request to unlock this account was already sent

) Else (



If Exist \\Server\UnlockAccounts$\Account.%Int.AccountName% (

Echo Request to unlock account %Int.AccountName% is registered, please wait few minutes and try it again

) Else (

Echo WARNING:  Request to unlock account %Int.AccountName%  was not created, please contact your IT support



This script is really simple, you just specify account name and then you will see if request (file) was successfully created or not.


Now we need to perform just last step – create scheduled task called UnlockAccountEngine and schedule it to run every 3 minutes (!).


What will happen? Every 3 minutes script UnlockAccountEngine will run and it will unlock any account that is locked. Extremely simple, but also extremely useful in fact :)


There are many advantages – this script wont hang, you don’t need to delegate any privileges, you can use scripts, web pages, even emails to generate such files (to do something, you just create one file, can it be simplier?)…


There are many different scenarios what you can do with batch engines. For example if you are deployment guy, you can let users “request” software based on their needs, or you can run some program on remote machine (VNC server?) and many many other options.

Are you too lazy to write scripts? Use tools to do that :)

Are you too lazy to write scripts or are you same sclerosis as I do?

 Cant you remember what is the name of property/function you are trying to use?

 I found it interesting that many people that are working a lot with scripts dont know “code generators” from Microsoft. I personally love them whenever I need to touch vb code:

Microsoft got three of them (three major ;))

 There are more available like HTA Matic etc, however this three I like to use (specially ADSIMatic and WMICodeGenerator). To see all scripting tools, check this webpage.