About Ed Hands

 I have been working in the IT field for over twenty years.  

In addition to spending time with my beautiful wife and two lovely daughters,  I enjoy practicing the guitar, Tae Kwon Do, reading, and grilling out  I am always trying to plan the perfect road-trip with my family.  Hopefully there will be coffee.

The purpose of this blog is to journal my experience in the IT field and hopefully provide a useful guide to those doing likewise.  And to journal my random musings on technology, computers, or whatever else strikes my fancy.  Adult ADD FTW!!!!  Ohhh...look...something shiny....

 

Follow me!
Navigation
BlogTopSites
Technology Blogs
technology blogs
Web Directory
OnToplist is optimized by SEO
Add blog to our directory.
ping web site via FeedShark
Shameless Self-Promotion

 

 

« The Exorcist. A cautionary tale in high expectations and disappointment. | Main | AmbiScience Zen Master Bundle App »
Sunday
Aug212011

Batch file magic. Part 1.

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:

  1. The end user has a batch file that creates a simple text file withing a network share.
  2. Task manager runs a batch file every five minutes that looks to the file created on that network share
  3. 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?

 

 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments

There are no comments for this journal entry. To create a new comment, use the form below.

PostPost a New Comment

Enter your information below to add a new comment.

My response is on my own website »
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>