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....

 

Google

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

 

 

Ads (Please help support this site. Thanks!)

Entries in batch file (2)

Friday
Jan202012

DOS and the Attrib Command

Today I was working on a problem that seemed to have no easy answer other than using a VB script of a batch file. Yet I found one in lowly DOS commands. 

The issue that I was having we as that I had a large number of directories that I need to change that attibutes on.  The folders all had the hidden and system attribute and I wanted to change it so that they could be seen.

I started working on a batch file to run the attrib -s -h on each folder but was having a probelm that, even though it seemed to process the command correctly, it failed to actually change the attibute.

Then as I was looking at the switches for the attrib command I found the /S /D switches that I never knew about.

So my long batch file that I was creating and testing for 90 minutes was simply replaced by this:

attrib -r -s /S /D

Voila!  Done.

...Just in time to go home for lunch!

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?