• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 263
  • Last Modified:

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 !
0
NetMaxtor
Asked:
NetMaxtor
  • 4
  • 2
1 Solution
 
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%
0
 
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.

regards

Steve
0
 
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:

Source01=x:\path\to\your\files

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.
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
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.

Steve
0
 
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 !



0
 
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.

Steve
0
 
NetMaxtorAuthor Commented:
Sure I will !!
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now