Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

DOS batch file help?

Thread Tools
 
Search this Thread
 
Old 16 May 2002, 10:47 AM
  #1  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Question

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
Old 16 May 2002, 12:11 PM
  #2  
father_jack
Scooby Regular
 
father_jack's Avatar
 
Join Date: Jul 2001
Posts: 1,112
Likes: 0
Received 0 Likes on 0 Posts
Post

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
Old 16 May 2002, 01:51 PM
  #3  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Thumbs up

FJ, that looks superb

Cheers,
Stefan
Old 16 May 2002, 03:39 PM
  #4  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Question

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
Old 17 May 2002, 09:54 AM
  #5  
father_jack
Scooby Regular
 
father_jack's Avatar
 
Join Date: Jul 2001
Posts: 1,112
Likes: 0
Received 0 Likes on 0 Posts
Thumbs up

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]
Old 17 May 2002, 02:37 PM
  #6  
ozzy
Scooby Regular
Thread Starter
 
ozzy's Avatar
 
Join Date: Nov 1999
Location: Scotland, UK
Posts: 10,504
Likes: 0
Received 1 Like on 1 Post
Thumbs up

Thanks FJ, I'll check the version of DOS I'm using. It should be 7 as it's a Win95 bootdisk image.

Cheers,
Stefan
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
01 October 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
30 September 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
26 September 2015 08:00 AM
Littleted
Computer & Technology Related
0
25 September 2015 08:44 AM



Quick Reply: DOS batch file help?



All times are GMT +1. The time now is 08:14 AM.