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 24 May 2002, 03:26 PM
  #1  
Chris J
Scooby Regular
Thread Starter
 
Chris J's Avatar
 
Join Date: Sep 2001
Posts: 283
Likes: 0
Received 0 Likes on 0 Posts
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
Old 24 May 2002, 03:34 PM
  #2  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

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

Probably is possible though.

David
Old 24 May 2002, 03:40 PM
  #3  
Chris J
Scooby Regular
Thread Starter
 
Chris J's Avatar
 
Join Date: Sep 2001
Posts: 283
Likes: 0
Received 0 Likes on 0 Posts
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]
Old 24 May 2002, 03:58 PM
  #4  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
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
Old 24 May 2002, 04:32 PM
  #5  
Chris J
Scooby Regular
Thread Starter
 
Chris J's Avatar
 
Join Date: Sep 2001
Posts: 283
Likes: 0
Received 0 Likes on 0 Posts
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
Old 24 May 2002, 04:45 PM
  #6  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
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
Old 24 May 2002, 04:52 PM
  #7  
Chris J
Scooby Regular
Thread Starter
 
Chris J's Avatar
 
Join Date: Sep 2001
Posts: 283
Likes: 0
Received 0 Likes on 0 Posts
Post

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


Chris

Trending Topics

Old 24 May 2002, 05:11 PM
  #8  
Silent Monkey
Scooby Regular
 
Silent Monkey's Avatar
 
Join Date: May 2001
Posts: 432
Likes: 0
Received 0 Likes on 0 Posts
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
Old 24 May 2002, 05:19 PM
  #9  
Chris J
Scooby Regular
Thread Starter
 
Chris J's Avatar
 
Join Date: Sep 2001
Posts: 283
Likes: 0
Received 0 Likes on 0 Posts
Post

Hi

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

Cheers

Chris
Old 24 May 2002, 05:31 PM
  #10  
Puff The Magic Wagon!
Moderator
Support Scoobynet!
iTrader: (2)
 
Puff The Magic Wagon!'s Avatar
 
Join Date: May 2000
Location: From far, far away...
Posts: 16,978
Received 15 Likes on 9 Posts
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]
Old 25 May 2002, 01:56 AM
  #11  
David_Wallis
Scooby Regular
 
David_Wallis's Avatar
 
Join Date: Nov 2001
Location: Leeds - It was 562.4bhp@28psi on Optimax, How much closer to 600 with race fuel and a bigger turbo?
Posts: 15,239
Likes: 0
Received 1 Like on 1 Post
Post

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


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



Quick Reply: batch files and incrementin environment vars



All times are GMT +1. The time now is 02:47 PM.