Struggling with variables

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
scriptnewbie
Posts: 3
Joined: 24 Feb 2010 05:24

Struggling with variables

#1 Post by scriptnewbie » 24 Feb 2010 17:21

Hi,

I am writing a simple DOS script to add a number of URL's into the registy in incremental values. The user will define the URL as

SET URL0=sitename

The issue is that when I loop around, I want to add 5 sites, I cannot get the variable to set correctly, I am using

SET "SITEURL=%URL%%SITETOADD%", but I want this to SET the details held in the variable URLX (ie the site)

Can someone offer me some help ?

Code snippet is posted below (obvously some variables are defined further up the code) ... please forgive the less than elegant scripting ;)


SET SITENUMBER=%COUNT%
SET SITETOADD=0

SET NUMBEROFSITESTOADD=5

SET URL0=acas.org.uk
SET URL1=google.co.uk
SET URL2=bbc.co.uk

:_ADD1SITE

IF %NUMBEROFSITESTOADD%==0 GOTO _END

SET "SITEURL=URL%SITETOADD%"

SET "SITEADD=%LOCATION% %VALUE%%SITENUMBER% %LOCATION2% %SITEURL%"

REG ADD %SITEADD%

SET /a SITENUMBER+=1
SET /a NUMBEROFSITESTOADD-=1

GOTO _ADD1SITE

scriptnewbie
Posts: 3
Joined: 24 Feb 2010 05:24

Re: Struggling with variables

#2 Post by scriptnewbie » 26 Feb 2010 10:14

Can anyone help me with this .... ?

aGerman
Expert
Posts: 3746
Joined: 22 Jan 2010 18:01
Location: Germany

Re: Struggling with variables

#3 Post by aGerman » 28 Feb 2010 15:52

Try this line:

CALL SET "SITEURL=%%URL%SITETOADD%%%"

Regards
aGerman

scriptnewbie
Posts: 3
Joined: 24 Feb 2010 05:24

Re: Struggling with variables

#4 Post by scriptnewbie » 01 Mar 2010 10:20

aGerman - Wonderfull -- that worked a treat!

Many thanks --- much appreciated.

Post Reply