One piece of software we use is called PowerTools for Windows (PTW.) Honestly, I have no idea what this software does. Something about electrical engineering. But it doesn't really matter. What is important for my purposes here is that it uses a licensing program called NetHASP. NetHASP monitors a USB key and hands out the licenses for clients as necessary and keeps track of them as they are used and returned.
It also doesn't work very well.
On occasion, it fails to release a license. In order for it to start working again the NetHASP service needs to be stop and restarted. This puts a burden on me and makes it inconvenient for the end user as they must stop or postpone working until I can find time to log in to the server and restart the server. And if I happen to be on the road or in a place I can't get to a PC to remote into the server, then that inconvenience turns into a real loss in dollars, this is not a good situation.
Another solution needed to be put in place.
So I developed a plan to use batch files and the task schedule built into Windows server to allow the end user to restart the service themself.
In general, it works like this:
- The end user has a batch file that creates a simple text file withing a network share.
- Task manager runs a batch file every five minutes that looks to the file created on that network share
- If the file is found, it restarts the service and deletes the text file.
The first part is to put a batch file on the end user's pc that creates a text file on a server share. For this, I do make a batch file something like this:
echo Hello world! >> \\server\networkshare\nethasp.txt"
The on the server I create a batch file that looks for the output text file from the previous batch file.
if exist \\server\networkshare\nethasp.txt goto process_it
echo The file nethasp.txt does not exist
exit /b
:process_it
net stop "HASP Loader"
echo "HASP Loader Stopped"
net start "HASP Loader"
echo "Hasp Loader Started"
del \\server\networkshare\nethasp.txt
Then on the server, I set up a scheduled task to run the task once every five minutes:



Once set up, the schedules looks for the file every five minutes and if it finds the trigger file, it restarts the service on the server for the end user.
Pretty sneaky, eh?