Re: environment variable
From: Big D (BigDaddy_at_newsgroup.nospam)
Date: 01/31/05
- Next message: Curtis Fray: "Re: Rename files with specific file extension"
- Previous message: Steve Fulton: "Re: Rename files with specific file extension"
- In reply to: McKirahan: "Re: environment variable"
- Next in thread: McKirahan: "Re: environment variable"
- Reply: McKirahan: "Re: environment variable"
- Messages sorted by: [ date ] [ thread ]
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
>
>
- Next message: Curtis Fray: "Re: Rename files with specific file extension"
- Previous message: Steve Fulton: "Re: Rename files with specific file extension"
- In reply to: McKirahan: "Re: environment variable"
- Next in thread: McKirahan: "Re: environment variable"
- Reply: McKirahan: "Re: environment variable"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|