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:
IsComputer /OS:Windows2003
Or, maybe just computers that have ‘server’ in their name:
IsComputer /Name:*server*
You can also get it to just run on your 64 bit computers like this:
IsComputer /Platform:64
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:
@echo off
IsComputer /OS:Classic /quiet /name:rack*
if ERRORLEVEL 1 goto RUN_SCRIPT
if ERRORLEVEL 0 goto EXIT_SCRIPT
:RUN_SCRIPT
REM Your conditional batch statements would go here
echo Hello
:EXIT_SCRIPT
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 support@intelliadmin.com
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
{ 16 comments… read them below or add one }
Great as usual.
Thanks for sharing!
Great tool steve. I have a convoluted VBScript that handles this. I like your freebie better. Thanks!
Hello Steve
Is there any way to make a check like this against a username or windows group?
Glad to hear it helped you out Josh.
Hello Jen. You might want to check out another free tool of ours:
http://www.intelliadmin.com/index.php/2010/11/check-group-membership-from-a-batch-file/
Keep those free tools comin Steve. Love the USB history viewer too 🙂
Hello David – glad you like the free tools. There will be more…still lots of stuff we are working on that we want to put out there.
Awesome. I was just looking for something like this. We use a naming convention for our computers, and I wanted to map printers based on the name of the computer in my logon scripts. This works perfect for me!
Glad to hear it Miles
Great tip as usual steve. Please keep it up
Steve, cool tool. Does this work on Windows 2000?
Hello Mathew,
Yes it works fine on 2000 Workstation, and Server
Hi,
Would there be any chance you could add an extra feature to see whether the OS is 32 or 64 bit as well. Otherwise awesome tool.
Thanks
Grant.
Hello Grant,
Just added the option. Here is the syntax:
/platform:[32/64]
So for example, to match a 32 bit system it would look like this:
/platform:32
Also, we added support for Windows 8 server and client in the os version detection.
Get the new version from our download page. It should have v1.1 in the header and a copyright of 2012 when you run it from the command line
Thank you steve for this update. I am deploying a few x64 machines now and this really helps!
When I run the IsComputer.exe file, nothing happens and I keep getting the invalid command error from the command prompt when I attempt to use the IsComputer command. How exactly are you suppose to implement the IsComputer.exe file?