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.

batch files and incrementin environment vars

Thread Tools
 
Search this Thread
 
Old May 24, 2002 | 03:26 PM
  #1  
Chris J's Avatar
Chris J
Thread Starter
Scooby Regular
 
Joined: Sep 2001
Posts: 283
Likes: 0
Post

Hi,

I am trying to increment/decrement an environment variable every time a batch file is run. Is this possible and if so how?

Cheers in advance

Chris
Reply
Old May 24, 2002 | 03:34 PM
  #2  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Post

does it have to be a batch file or can you use windows scripting host??

Probably is possible though.

David
Reply
Old May 24, 2002 | 03:40 PM
  #3  
Chris J's Avatar
Chris J
Thread Starter
Scooby Regular
 
Joined: Sep 2001
Posts: 283
Likes: 0
Post

I'd prefer a batch file. I already have a batch fle to run a java program, but each time you run it it needs a different port number supplied. Previously it would only be run once, but now I am testing multi session/user stuff, and I would prefer not to have 5 different bat kicking around which are identical apart from this port number.

Chris

[Edited by Chris J - 5/24/2002 3:43:03 PM]
Reply
Old May 24, 2002 | 03:58 PM
  #4  
Puff The Magic Wagon!'s Avatar
Puff The Magic Wagon!
Moderator
25 Year Member
iTrader: (2)
 
Joined: May 2000
Posts: 16,980
Likes: 15
From: From far, far away...
Post

Every time you run the prog, create a file called 1234.fil (empty)

Enviro used that number but adds a number to the .fil, then del *.fil, then create .fil with the same number as the one in just used by the enviro.

Well clumsy, but you could run a menu option to check the .fil number to see if it was in range that you specified, then either delete & start from the bottom number or just add on.

Its Friday & I have a large headache
Reply
Old May 24, 2002 | 04:32 PM
  #5  
Chris J's Avatar
Chris J
Thread Starter
Scooby Regular
 
Joined: Sep 2001
Posts: 283
Likes: 0
Post

Cheers for you help guys.

PTMW, I have no idea what you mean, but I have hacked it by putting in a load of if statments .

Chris
Reply
Old May 24, 2002 | 04:45 PM
  #6  
Puff The Magic Wagon!'s Avatar
Puff The Magic Wagon!
Moderator
25 Year Member
iTrader: (2)
 
Joined: May 2000
Posts: 16,980
Likes: 15
From: From far, far away...
Question

Anyone out there understand what I think I meant?

If I hadn't got loads of work and another meeting, I'd be on my way home to bed
Reply
Old May 24, 2002 | 04:52 PM
  #7  
Chris J's Avatar
Chris J
Thread Starter
Scooby Regular
 
Joined: Sep 2001
Posts: 283
Likes: 0
Post

...But the hack doesn't work as the updated environment variable is not picked up by other dos windows .


Chris
Reply
Old May 24, 2002 | 05:11 PM
  #8  
Silent Monkey's Avatar
Silent Monkey
Scooby Regular
 
Joined: May 2001
Posts: 432
Likes: 0
Post

What OS? The NT resource kit has the setx command which sets env variables permanently, they are then available to future command windows but not the current one.

I'd have thought some variation on Puff's suggestion would be possible, although I haven't got the faintest idea what he was talking about
Reply
Old May 24, 2002 | 05:19 PM
  #9  
Chris J's Avatar
Chris J
Thread Starter
Scooby Regular
 
Joined: Sep 2001
Posts: 283
Likes: 0
Post

Hi

It's running on Win2k server. tried setx but it reported in as an unrecognised program etc.

Cheers

Chris
Reply
Old May 24, 2002 | 05:31 PM
  #10  
Puff The Magic Wagon!'s Avatar
Puff The Magic Wagon!
Moderator
25 Year Member
iTrader: (2)
 
Joined: May 2000
Posts: 16,980
Likes: 15
From: From far, far away...
Post

I'll have a basic go @ trying to explain myself...



exist file.* ? [* should be a file extension made up of a the numbers that corespond to the port numbers but in this case its just checking that there is a file]

if yes, use the number of the highest file extension +1 as the enviromental variable for port number

copy file.* number to file.(whatever the new enviromental variable number is)

run java program port: whatever the new enviromental variable number is

end


if no, copy file.xxx to file. [number before 1st avail port no:]

then repeat the first steps.



If there is a finate number to ports

exist file.[max no]?

if yes, delete *.fil (that aren't locked as being part of the batch process?) and run the middle section (OK not in the correct order of process) but that will loop the port numbers back to the start.

Only prob I see is if with limited ports there may be a user already in session on that port, in which case, how about running the java app as part of the dos shell (if poss) so that its only when it ends, it then deletes the enviromental variable or port number file it created before it completely ends its session.



[Edited by Puff The Magic Wagon! - 5/24/2002 5:36:34 PM]
Reply
Old May 25, 2002 | 01:56 AM
  #11  
David_Wallis's Avatar
David_Wallis
Scooby Regular
 
Joined: Nov 2001
Posts: 15,239
Likes: 1
From: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Post

mail me if you havent sorted and I will do it for you


David
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
yabbadoo4
ScoobyNet General
11
Sep 30, 2015 10:33 PM
fat-thomas
Subaru Parts
6
Sep 30, 2015 06:03 PM
Nick_Cat
Computer & Technology Related
2
Sep 26, 2015 08:00 AM
Littleted
Computer & Technology Related
0
Sep 25, 2015 08:44 AM
riiidaa
ScoobyNet General
1
Sep 12, 2015 11:52 AM




All times are GMT +1. The time now is 03:10 AM.