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 May 16, 2002 | 10:47 AM
  #1  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
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
Reply
Old May 16, 2002 | 12:11 PM
  #2  
father_jack's Avatar
father_jack
Scooby Regular
 
Joined: Jul 2001
Posts: 1,112
Likes: 0
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
Reply
Old May 16, 2002 | 01:51 PM
  #3  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
Thumbs up

FJ, that looks superb

Cheers,
Stefan
Reply
Old May 16, 2002 | 03:39 PM
  #4  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
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
Reply
Old May 17, 2002 | 09:54 AM
  #5  
father_jack's Avatar
father_jack
Scooby Regular
 
Joined: Jul 2001
Posts: 1,112
Likes: 0
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]
Reply
Old May 17, 2002 | 02:37 PM
  #6  
ozzy's Avatar
ozzy
Thread Starter
Scooby Regular
 
Joined: Nov 1999
Posts: 10,504
Likes: 1
From: Scotland, UK
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
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
blackieblob
ScoobyNet General
4
Oct 1, 2015 11:37 AM
yabbadoo4
ScoobyNet General
11
Sep 30, 2015 10:33 PM
Nick_Cat
Computer & Technology Related
2
Sep 26, 2015 08:00 AM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM




All times are GMT +1. The time now is 09:47 PM.