DOS batch file help?
#1
Scooby Regular
Thread Starter
Haven't touched batch files for a few years so I'm very rusty.
I have a utility that outputs the Service Tag from a Dell PC. It can't be used directly in a batch file, but I can pipe it out to a text file easily i.e. asset.com > tag.txt
As an example, the text file tag.txt would contain the following:-
ASSET -- Version 2.02 (C) Copyright 1993-2000 Dell Computer Corporation
Service Tag => LE7WW
Asset Tag =>
Owner Tag =>
Is there anyway of searching the text file, locating the tag (in this case LE7WW) and adding it to the following command:-
ghstwalk /CN="RDF-SCO-<tag>" /SURE /RB
This would give me the command
ghstwalk /CN="RDF-SCO-LE7WW" /SURE /RB
Hope that makes some sense, but the idea is to have one boot disk that will set the workstation name using the service tag as this is unique for each PC. Also saves me either having 100 individual disks or having to manually type the command at every PC.
Stefan
I have a utility that outputs the Service Tag from a Dell PC. It can't be used directly in a batch file, but I can pipe it out to a text file easily i.e. asset.com > tag.txt
As an example, the text file tag.txt would contain the following:-
ASSET -- Version 2.02 (C) Copyright 1993-2000 Dell Computer Corporation
Service Tag => LE7WW
Asset Tag =>
Owner Tag =>
Is there anyway of searching the text file, locating the tag (in this case LE7WW) and adding it to the following command:-
ghstwalk /CN="RDF-SCO-<tag>" /SURE /RB
This would give me the command
ghstwalk /CN="RDF-SCO-LE7WW" /SURE /RB
Hope that makes some sense, but the idea is to have one boot disk that will set the workstation name using the service tag as this is unique for each PC. Also saves me either having 100 individual disks or having to manually type the command at every PC.
Stefan
#2
This will work from the command line. Use %%A instead of %A if using this in a batch file.
FOR /F "EOL=- TOKENS=4" %A IN ('FIND /I "SERVICE TAG" TAG.TXT') DO ECHO ghstwalk /CN="RDF-SCO-%A" /SURE /RB>>MYCOMMAND.BAT
FOR /F "EOL=- TOKENS=4" %A IN ('FIND /I "SERVICE TAG" TAG.TXT') DO ECHO ghstwalk /CN="RDF-SCO-%A" /SURE /RB>>MYCOMMAND.BAT
#4
Scooby Regular
Thread Starter
FJ,
What's the first part of the FOR statment doing. The command as is complains of a syntaxt error.
Am I right in thinking the second part looks for "SERVICE TAG" in the TAG.TXT file, then pipes the command to the batch file MYCOMMAND.BAT?
Stefan
What's the first part of the FOR statment doing. The command as is complains of a syntaxt error.
Am I right in thinking the second part looks for "SERVICE TAG" in the TAG.TXT file, then pipes the command to the batch file MYCOMMAND.BAT?
Stefan
#5
The tokens part splits the asset tag information into 4 parts
Asset, Service tag , = and > then fires it into the mycommand.bat file.
It works for me as is.
Create a tag.txt with this in it:
ASSET -- Version 2.02 (C) Copyright 1993-2000 Dell Computer Corporation
Service Tag => LE7WW
Asset Tag =>
Owner Tag =>
Run the command and you'll get a mycommand.bat with this in it:
ghstwalk /CN="RDF-SCO-LE7WW" /SURE /RB
edited to say - this needs to be DOS 7 to work i.e. NT or above and make sure you put in %% if its inside a batch file rather than command line.
[Edited by father_jack - 5/17/2002 9:55:54 AM]
Asset, Service tag , = and > then fires it into the mycommand.bat file.
It works for me as is.
Create a tag.txt with this in it:
ASSET -- Version 2.02 (C) Copyright 1993-2000 Dell Computer Corporation
Service Tag => LE7WW
Asset Tag =>
Owner Tag =>
Run the command and you'll get a mycommand.bat with this in it:
ghstwalk /CN="RDF-SCO-LE7WW" /SURE /RB
edited to say - this needs to be DOS 7 to work i.e. NT or above and make sure you put in %% if its inside a batch file rather than command line.
[Edited by father_jack - 5/17/2002 9:55:54 AM]
Thread
Thread Starter
Forum
Replies
Last Post