Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how do we create parameter file for batch script?

Posted on 2014-12-10
4
Medium Priority
?
466 Views
Last Modified: 2014-12-10
i have FILE X with list of values for A,B,C as 1,2,3. i have FILE Y where i use these values A,B, and C wherever required in FILE B. it should get the value of A,B,C from FILE X and show as 1,2,3 respectively.

please let me know if i can be more clear !
0
Comment
Question by:naveen mullaguri
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 2000 total points
ID: 40490956
You can call another batch, or read one.

e.g.

filex.cmd

@echo off
set A=1
set B=2
set C=3

Open in new window



filey.cmd
@echo off
call filex.cmd
echo Now they are %a% %b% %c%

Open in new window


or you can read contents of a file, e.g.

filex.txt
A,1
B,2
C,3

Open in new window


@Echo off
for /f "tokens=1,2 delims=," %%a in ('type filex.txt') do set %%a=%%b
echo %a%, %b%, %c%

Open in new window


That should read filex.txt and for each line use the first bit before , as the variable name and the bit after the , as the value dynamically.

Is that what you are after?
0
 
LVL 85

Expert Comment

by:oBdA
ID: 40490970
If your "file x" is indeed has indeed the content as "1,2,3", you can import this into a batch file like this:
@echo off
setlocal
set ValueFile=x.txt
for /f "tokens=1-3 delims=," %%a in ('type "%ValueFile%"') do (
	set A=%%a
	set B=%%b
	set C=%%c
)
echo A: '%A%', A: '%B%', C: '%C%'

Open in new window

If not, please provide a concrete sample.
0
 

Author Closing Comment

by:naveen mullaguri
ID: 40491644
Thank you so much.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 40491697
No problem, ask if not sure on anything.

Steve
0

Featured Post

Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An introduction to the wonderful sport of Scam Baiting.  Learn how to help fight scammers by beating them at their own game. This great pass time helps the world, while providing an endless source of entertainment. Enjoy!
Windows Server 2003 introduced persistent Volume Shadow Copies and made 2003 a must-do upgrade.  Since then, it's been a must-implement feature for all servers doing any kind of file sharing.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question