| 1. |
Solve : Cross Reference Company Name and Computer Name? |
|
Answer» Sorry if the title was misleading, I'm not really sure how to word what I want to do. I would like to add a command to a tool I use to manage our servers every day. The logic is this: Squashman - I imagined using a text file - FarmID.txtAnd the format of this file will be???We can tell you how to compare parts of a string (set /? has INFO) but to give you something that will work for you depends on the file format, as Squashman said.Sorry, I disappeared. I've been very sick. I don't THINK I really put much thought into what was going to be in the file, just that there would be a file. Hmmmm . . . I'm not really sure how the file should read. Could something like this work: TS888-101=Widget Company TS888-102=Widget Company TS899-101=Gadget Company etc.? If not, can you suggest a format? Thank, MJThis should work with the format you listed above. It's untested: Code: [Select]@echo off set "name=%computername:~0,5%" set "coname=" for /f "tokens=1,2,* delims==-" %%a in ('type "companylist.txt") do if "%name%"=="%%a" set "coname=%%c" if defined coname ( echo from %name% the company found was "%coname%" ) else ( echo no company name was found ) pause |
|