Windows batch scripting path referral file ?

Hi Experts,

I was writing a simple batch file and I need to get the resource paths in to one separate file.

echo off
mkdir c:\Inetpub\wwwroot\MyFolder
xcopy d:\Source01\* c:\Inetpub\wwwroot\MyFolder /s /i
CACLS c:\Inetpub\wwwroot\MyFolder /E /T /C /G server01\ASPNET:F                        

mkdir d:\Folder01
mkdir d:\Folder01\Sub01
mkdir d:\Folder01\Sub02
mkdir d:\Folder01\Sub03
xcopy d:\Source02\* d:\Folder01 /s /i
CACLS d:\Folder01 /E /T /C /G server01\ASPNET:F server01\User01:F
NET SHARE Share01$=d:\Folder01 /grant:server01\User01,FULL

Likewise this script may be bit long. I need to make a resource path referrals file. In the referral file, at least I need to change Source01 and Source02 folder location. Hope you got my point? How do I make this happen, please advice!

Thanks !
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Steve KnightIT ConsultancyCommented:
Well an easy way would be to do this:

@echo off
REM Resource data file "resource.cmd"
SET source01=whatever
SET source02=whatever

@echo off
call resource.cmd
echo the source directory is %source01%

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Steve KnightIT ConsultancyCommented:
or if you want to just store the path in the resource file (like an INI file) then we can extract it with some FOR commands.  Let me know.


Lee W, MVPTechnology and Business Process AdvisorCommented:
If you think that's a bit long, you should see my backup script.

To elaborate on what steve is referring to, create a text file called "sources.txt" (or whatever, but replace the name as appropriate below).  Each line should be like:


Then use for to extract the names.

For /f "tokens=2, delims==" %%a in (sources.txt) do SET Source01=%%a

Repeat as necessary for as many sources as you need.
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Steve KnightIT ConsultancyCommented:
Yeah that was what I was suggesting, was on the way out before...

By the time you add edit history, comments, error checking, email alerts and everything else to 'production' scripts 3-4 pages or more when printed isn't unusual.... and frankly if written right is perfectly maintainable.

NetMaxtorAuthor Commented:
dragon-it: it works well !! thanks a lot !!

leew: tnx to you too !

Steve: since you guys are experts on scripting, I would like to have some additional clues;

1. Restore IIS .xml file to a IIS 6 on Windows 2003 ? Configs on IIS virtual web site ?
2. Can I restore a MS-SQL DB using batch script?
3. Create a Windows Media server instant and do some configs ?

Basically I'm trying to make automated deployment of a IIS application.

Any ideas would be greatly appreciated !

Steve KnightIT ConsultancyCommented:
To keep it clean I suggest you raise some new questions for that /those.  Will pickup and look at it later for you then if someone else doesn;t get there first.

NetMaxtorAuthor Commented:
Sure I will !!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Batch

From novice to tech pro — start learning today.