Re: environment variable

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Big D (BigDaddy_at_newsgroup.nospam)
Date: 01/31/05


Date: Mon, 31 Jan 2005 08:15:07 -0500

I might be wrong but not sure how that helps. Being that an IP address is a
const in the script below, I could skip all the environment stuff and
already have the value.

Anyways I tried not to make this complicated with the first post. I can't
hard code the addresses because each site will have different addresses.
Each site would have script that they would run to get the addresses for
other files. What i actually do is I loop through multiple files that are
named ComputerIP##.bat.

N= a number. I have a "FOR" loop runing. I am running through a FOR loop
that builds each ComputerIP1.bat, ComputerIP2.bat, ComputerIP3.bat, etc.

VBSCRIPT statement
strCommand2 = "cmd.exe /c " & "CALL C:\createparms\Computer" & n & "IP.bat"

N= a number. I have a "FOR" loop runing. I am running through a FOR loop
that builds each ComputerIP1.bat, ComputerIP2.bat, ComputerIP3.bat, etc.

I need to grab each Computer IP address for other commands I am running.

I tried approaching differently meaning opening each file
s= ObjFile.ReadAll

But for some reason I would graB the IP but it would give me an extra line.
Not sure if this was because of carriage return and any other data in file.

I am just looking for the best approach to get a value out of a bat file. If
doing a call to set the variable in volitle memory and using that variable
is not possible then I am open to other approaches. For example, reading the
file. This is just a aprm file with a .bat extension.

Below is the complete layout of file:
SET BUnit=CORP
SET SiteNum=1000
SET SiteSubnet=255.255.255.0
SET SiteGateway=192.168.2.1
SET COMPUTERIP=192.168.2.12
SET ComputerName=
SET POSDNSServer=192.168.2.8,192.168.2.9

"McKirahan" <News@McKirahan.com> wrote in message
news:2ICdnRIBl7VSAGDcRVn-2Q@comcast.com...
> "Big D" <jeffbrownjr@gmail.com> wrote in message
> news:1107133270.545726.134300@c13g2000cwb.googlegroups.com...
> > In batch I can call a file that has the "SET" command being used and
> > use that value. For example,
> >
> > FileContents:
> > SET ComputerIP = 192.168.2.12
> > =============================================================
> >
> > CALL C:\createparms\Comp10IP.bat
> > ECHO %ComputerIP%
> >
> > The value is 192.168.2.12
> > =============================================================
> >
> >
> >
> > The problem experiencing is I can not seem to do the same in vbscript.
> > Below is a code snippet of what I am tring to accomplish. Everytime I
> > run the commands in the vbscript the value is NULL. I just want to
> > store value in memory and after I finish using value it is no longer
> > needed. Just like batch.(volitile memory)
> >
> >
> >
> > Set colSystemEnvVars = objShell.Environment("System")
> >
> > strCommand2 = "cmd.exe /c " & "CALL
> > C:\createparms\Comp10IP.bat"
> > strCommand3 = "cmd.exe /c " & "echo %ComputerIP%"
> > objShell.Run strCommand2, 0, True
> > objShell.Run strCommand3,0, True
> >
> > intComputerIPAddress = colSystemEnvVars("ComputerIP")
> > WScript.Echo intComputerIPAddress
> >
>
> Will this help?
>
> Const cENV = "192.168.2.12"
> Dim objWSS
> Set objWSS = CreateObject("WScript.Shell")
> Dim objENV
> Set objENV = objWSS.Environment("Volatile")
> WScript.Echo cENV & " = " &objENV(cENV)
> Set objENV = Nothing
> Set objWSS = Nothing
>
>



Relevant Pages

  • Re: Possible memory leak using $sth->{NAME} ?
    ... > routine seems to leak 1 SV per execution. ... > to be a fairly insignificant amount of memory. ... > of memory per trip through the loop. ... > version of the script where the loop executes once, ...
    (perl.dbi.users)
  • Re: Incude statement - is there such a thing?
    ... I can't imagine any memory usage issues. ... And it that WSF references ... other script files (as the Docs often suggest to be ... > you had 50 statements that you wanted to execute 1000 times in a loop. ...
    (microsoft.public.scripting.vbscript)
  • Re: Incude statement - is there such a thing?
    ... but have you noticed that you get poorer compile time messages when ... > if they are constantly loaded into memory or per script. ... you had 50 statements that you wanted to execute 1000 times in a loop. ...
    (microsoft.public.scripting.vbscript)
  • COM object, disposing?
    ... application called Swyx. ... All this is driven by standard VBScript. ... Now, the first time round I create my COM object within this GSE script, it ... I'm assuming that the COM object is somehow still in memory, ...
    (microsoft.public.dotnet.framework.interop)
  • Re: PHP memory garbage collection
    ... If I use a very large XML file then the PHP crashes inside the loop (Fatal error: Allowed memory size of 10485760 bytes exhausted) - indicating that the problem lies within loop somewhere. ... If PHP uses all the memory until the end of the script ...
    (comp.lang.php)