I got a question from one of our customers this week,
“Is there a way to run profile generator based on its workstation name? We want cached mode activated for laptops but not desktops. Or can you advise how this can be determined with the batch file?”
Actually we have had a tool internally that we have used for a long time. I decided to clean it up, and add it to our free tools.
It is called “IsComputer.exe” and you can get it from our downloads page
Here is how it works. You can give it two conditions – The version of Windows, or the name of the computer.
Lets say I want part of my script to only run on computers that are not Vista and above (Windows 2003, XP, and 2000) and start with the name LAPTOP:
IsComputer /name:LAPTOP* /os:CLASSIC
Or, I want it to only run on Windows 2003 computers:
Or, maybe just computers that have ‘server’ in their name:
You can also get it to just run on your 64 bit computers like this:
Those are just a few options – a complete list of options can be viewed by running it from the command line.
How do we get it to work with our batch file?
If a condition matches, the program will return 1. If it does not match it will return 0. Here is how we can create a simple script that will output ‘hello’ if we have a match:
IsComputer /OS:Classic /quiet /name:rack*
if ERRORLEVEL 1 goto RUN_SCRIPT
if ERRORLEVEL 0 goto EXIT_SCRIPT
REM Your conditional batch statements would go here
This example script will output ‘hello’ if the computer is running Windows 2003, and the name of the computer starts with ‘rack’.
You could put the batch file commands you want to execute right where the “echo hello” statement is.
Got a question, or an idea for a free tool? Let me know by mailing firstname.lastname@example.org
One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools