Discussion:
include (Windows client variable) in the installation path of VBScript
(too old to reply)
Diego Santos de Bem
2014-03-20 19:35:27 UTC
Permalink
Hello All,

My name is Diego and I found this group by performing google searches, i need so much help with this VBscript,

The script works well but I just need to call (SRV) windows System variable that contains the name of the local server.

All client machines (winxp) already have a system variable name (SRV) with value (name of local server)for example SRVADS001, because in our environment we have many offices with low-speed links, why the need to get the download file on the local server, so we avoid bandwidth consumption.

How i can Call SRV Variable and puts it on path
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS) ?

I need the download path of the file is correct as:

INSTALL_PATH = Chr (34) & "\\SRV (Variable)\Agent\AgInstall.exe" & Chr (34)


FY = The SRV variable just contains the name of local server, do not contain \\



VBscript

' Variable Declarations
'==================================
Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist
Dim REQUIRED_AGENT_VERSION
Dim REQUIRED_SERVER_IP
Dim INSTALL_PATH
Dim STR_PARAMETERS
Dim FULL_INSTALL_PATH

'======================================
' MUST CHANGE VARIABLES IN THIS SECTION
'======================================
REQUIRED_AGENT_VERSION="4.6.0"
REQUIRED_SERVER_IP="192.168.1.100:12300"
INSTALL_PATH = Chr(34) & "\\Server\NETLOGON\AgInstall.exe" & Chr(34)
STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) & "%PROGRAMFILES%\Framework\" & Chr(34) & " /SILENT"
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)

'======================================
' END CHANGE VARIABLES SECTION
'======================================
Const HKEY_LOCAL_MACHINE = &H80000002

CheckRegExist()

If (regExist=TRUE) Then

'==================================
' Get Registry Values
'==================================
agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Agent Version: " & agentVersion

dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Data Path: " & dataPath

'==================================
' Read XML Sitelist
'==================================

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load(dataPath & "\SiteList.xml")

Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
ipAddress = ElemList.item(0).getAttribute("ServerIP")
' MsgBox ipAddress & " " & InStr(REQUIRED_SERVER_IP,ipAddress)

'==================================
' Check Agent Version, ServerIP
'==================================

IF (agentVersion<REQUIRED_AGENT_VERSION) OR InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN

InstallNewAgent(FULL_INSTALL_PATH)

'MsgBox("Your agent is now up to date and configured correctly.")

ELSE

'MsgBox("Your agent is currently up to date and configured correctly.")

END IF

'Install Agent if Reg Does NOT exist

ELSE
InstallNewAgent(FULL_INSTALL_PATH)
END IF

'==================================
' Registry Reader
'==================================

Function ReadReg(RegPath)
Dim objRegistry, Key
Set objRegistry = CreateObject("Wscript.shell")
Key = objRegistry.RegRead(RegPath)
ReadReg = Key
End Function

'==================================
' Agent Installation
'==================================

Function InstallNewAgent(FULL_INSTALL_PATH)
Dim wshShell
Set wshShell = WScript.CreateObject ("WSCript.shell")

' MsgBox("Installing New Agent...")

wshshell.run FULL_INSTALL_PATH, 6, True
set wshshell = nothing
End Function

'==================================
' Check if Reg Key Exists
'==================================

Function CheckRegExist ()
Dim strComputer, objRegistry, strKeyPath, strValueName, strValue
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Network\Shared Components\Framework"
strValueName = "Version"

objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
'Wscript.Echo "The registry key does not exist."
regExist=FALSE
Else
'Wscript.Echo "The registry key exists. (" & strValue & ")"
regExist=TRUE
End If
End Function
R.Wieser
2014-03-21 08:51:04 UTC
Permalink
Hello Diego,

If I understood you correctly you're looking for this:

INSTALL_PATH = Chr (34) & "\\" & SRV & "\Agent\AgInstall.exe" & Chr (34)

Regards,
Rudy Wieser


-- Origional message:
Diego Santos de Bem <***@gmail.com> schreef in berichtnieuws
e1b45ad2-c427-40bf-9c16-***@googlegroups.com...
Hello All,

My name is Diego and I found this group by performing google searches, i
need so much help with this VBscript,

The script works well but I just need to call (SRV) windows System variable
that contains the name of the local server.

All client machines (winxp) already have a system variable name (SRV) with
value (name of local server)for example SRVADS001, because in our
environment we have many offices with low-speed links, why the need to get
the download file on the local server, so we avoid bandwidth consumption.

How i can Call SRV Variable and puts it on path
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS) ?

I need the download path of the file is correct as:

INSTALL_PATH = Chr (34) & "\\SRV (Variable)\Agent\AgInstall.exe" & Chr (34)


FY = The SRV variable just contains the name of local server, do not contain
\\



VBscript

' Variable Declarations
'==================================
Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist
Dim REQUIRED_AGENT_VERSION
Dim REQUIRED_SERVER_IP
Dim INSTALL_PATH
Dim STR_PARAMETERS
Dim FULL_INSTALL_PATH

'======================================
' MUST CHANGE VARIABLES IN THIS SECTION
'======================================
REQUIRED_AGENT_VERSION="4.6.0"
REQUIRED_SERVER_IP="192.168.1.100:12300"
INSTALL_PATH = Chr(34) & "\\Server\NETLOGON\AgInstall.exe" & Chr(34)
STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) &
"%PROGRAMFILES%\Framework\" & Chr(34) & " /SILENT"
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)

'======================================
' END CHANGE VARIABLES SECTION
'======================================
Const HKEY_LOCAL_MACHINE = &H80000002

CheckRegExist()

If (regExist=TRUE) Then

'==================================
' Get Registry Values
'==================================
agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data
Path")
'WScript.Echo "Agent Version: " & agentVersion

dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data
Path")
'WScript.Echo "Data Path: " & dataPath

'==================================
' Read XML Sitelist
'==================================

Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load(dataPath & "\SiteList.xml")

Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
ipAddress = ElemList.item(0).getAttribute("ServerIP")
' MsgBox ipAddress & " " & InStr(REQUIRED_SERVER_IP,ipAddress)

'==================================
' Check Agent Version, ServerIP
'==================================

IF (agentVersion<REQUIRED_AGENT_VERSION) OR
InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN

InstallNewAgent(FULL_INSTALL_PATH)

'MsgBox("Your agent is now up to date and configured correctly.")

ELSE

'MsgBox("Your agent is currently up to date and configured correctly.")

END IF

'Install Agent if Reg Does NOT exist

ELSE
InstallNewAgent(FULL_INSTALL_PATH)
END IF

'==================================
' Registry Reader
'==================================

Function ReadReg(RegPath)
Dim objRegistry, Key
Set objRegistry = CreateObject("Wscript.shell")
Key = objRegistry.RegRead(RegPath)
ReadReg = Key
End Function

'==================================
' Agent Installation
'==================================

Function InstallNewAgent(FULL_INSTALL_PATH)
Dim wshShell
Set wshShell = WScript.CreateObject ("WSCript.shell")

' MsgBox("Installing New Agent...")

wshshell.run FULL_INSTALL_PATH, 6, True
set wshshell = nothing
End Function

'==================================
' Check if Reg Key Exists
'==================================

Function CheckRegExist ()
Dim strComputer, objRegistry, strKeyPath, strValueName, strValue
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer &
"\root\default:StdRegProv")

strKeyPath = "SOFTWARE\Network\Shared Components\Framework"
strValueName = "Version"

objRegistry.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue

If IsNull(strValue) Then
'Wscript.Echo "The registry key does not exist."
regExist=FALSE
Else
'Wscript.Echo "The registry key exists. (" & strValue & ")"
regExist=TRUE
End If
End Function
Evertjan.
2014-03-21 09:37:41 UTC
Permalink
Post by R.Wieser
INSTALL_PATH = Chr (34) & "\\" & SRV & "\Agent\AgInstall.exe" & Chr (34)
or:

INSTALL_PATH = """\\" & SRV & "\Agent\AgInstall.exe"""
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Diego Santos de Bem
2014-03-21 13:48:33 UTC
Permalink
Post by Diego Santos de Bem
Hello All,
My name is Diego and I found this group by performing google searches, i need so much help with this VBscript,
The script works well but I just need to call (SRV) windows System variable that contains the name of the local server.
All client machines (winxp) already have a system variable name (SRV) with value (name of local server)for example SRVADS001, because in our environment we have many offices with low-speed links, why the need to get the download file on the local server, so we avoid bandwidth consumption.
How i can Call SRV Variable and puts it on path
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS) ?
INSTALL_PATH = Chr (34) & "\\SRV (Variable)\Agent\AgInstall.exe" & Chr (34)
FY = The SRV variable just contains the name of local server, do not contain \\
VBscript
' Variable Declarations
'==================================
Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist
Dim REQUIRED_AGENT_VERSION
Dim REQUIRED_SERVER_IP
Dim INSTALL_PATH
Dim STR_PARAMETERS
Dim FULL_INSTALL_PATH
'======================================
' MUST CHANGE VARIABLES IN THIS SECTION
'======================================
REQUIRED_AGENT_VERSION="4.6.0"
REQUIRED_SERVER_IP="192.168.1.100:12300"
INSTALL_PATH = Chr(34) & "\\Server\NETLOGON\AgInstall.exe" & Chr(34)
STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) & "%PROGRAMFILES%\Framework\" & Chr(34) & " /SILENT"
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)
'======================================
' END CHANGE VARIABLES SECTION
'======================================
Const HKEY_LOCAL_MACHINE = &H80000002
CheckRegExist()
If (regExist=TRUE) Then
'==================================
' Get Registry Values
'==================================
agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Agent Version: " & agentVersion
dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Data Path: " & dataPath
'==================================
' Read XML Sitelist
'==================================
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load(dataPath & "\SiteList.xml")
Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
ipAddress = ElemList.item(0).getAttribute("ServerIP")
' MsgBox ipAddress & " " & InStr(REQUIRED_SERVER_IP,ipAddress)
'==================================
' Check Agent Version, ServerIP
'==================================
IF (agentVersion<REQUIRED_AGENT_VERSION) OR InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN
InstallNewAgent(FULL_INSTALL_PATH)
'MsgBox("Your agent is now up to date and configured correctly.")
ELSE
'MsgBox("Your agent is currently up to date and configured correctly.")
END IF
'Install Agent if Reg Does NOT exist
ELSE
InstallNewAgent(FULL_INSTALL_PATH)
END IF
'==================================
' Registry Reader
'==================================
Function ReadReg(RegPath)
Dim objRegistry, Key
Set objRegistry = CreateObject("Wscript.shell")
Key = objRegistry.RegRead(RegPath)
ReadReg = Key
End Function
'==================================
' Agent Installation
'==================================
Function InstallNewAgent(FULL_INSTALL_PATH)
Dim wshShell
Set wshShell = WScript.CreateObject ("WSCript.shell")
' MsgBox("Installing New Agent...")
wshshell.run FULL_INSTALL_PATH, 6, True
set wshshell = nothing
End Function
'==================================
' Check if Reg Key Exists
'==================================
Function CheckRegExist ()
Dim strComputer, objRegistry, strKeyPath, strValueName, strValue
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Network\Shared Components\Framework"
strValueName = "Version"
objRegistry.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
If IsNull(strValue) Then
'Wscript.Echo "The registry key does not exist."
regExist=FALSE
Else
'Wscript.Echo "The registry key exists. (" & strValue & ")"
regExist=TRUE
End If
End Function
Hello all!

Done with success!! Thank you!, now the validation of the installation of the agent is not running always that run this script code it validates the version of the agent installed if it is not the resent version of agent or inexistent it starts Setup if already exists the script has to STOP and that is not happening. could you help me? sorry guys really need help because i dont know how to write, is a emergency and i will study later. thank you so much
R.Wieser
2014-03-22 10:22:58 UTC
Permalink
Diego,

The test if the update should be done seems to revolve around the below line
:

IF (agentVersion<REQUIRED_AGENT_VERSION) OR
InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN

My suggestion is to print-out all the arguments in that comparision as well
as the result of the partial and full comparisions. That way you can see
and check if you get the expected result. If nothing is shown it indicates
that line is never reached.

My guess is that they are not, and by finding out which one isn't you can
backward in your code to check the routine that creates it, and see what it
does wrong.

Also display a line just below the "if" and "else" to show you which branch
is actually taken. That way you can make *sure* that something is, or isn't
happening. Maybe everything

You could also put message boxes in all three possibilities (no agent, agent
not upto date, agent uptodate) to see where the code goes.


Now I look at it maybe its even the "If (regExist=TRUE) Then" line that
doesn't quite do its work (display the contents of "regExist" just before
the "if" !), and it tries to install a new agent every time ...

I'm sorry, I think that thats all I (we?) can do for you.

Regards,
Rudy Wieser


-- Origional message:
Diego Santos de Bem <***@gmail.com> schreef in berichtnieuws
97653808-99ba-4747-b4d9-***@googlegroups.com...
Em quinta-feira, 20 de março de 2014 16h35min27s UTC-3, Diego Santos de Bem
Post by Diego Santos de Bem
Hello All,
My name is Diego and I found this group by performing google searches, i
need so much help with this VBscript,
Post by Diego Santos de Bem
The script works well but I just need to call (SRV) windows System
variable that contains the name of the local server.
Post by Diego Santos de Bem
All client machines (winxp) already have a system variable name (SRV) with
value (name of local server)for example SRVADS001, because in our
environment we have many offices with low-speed links, why the need to get
the download file on the local server, so we avoid bandwidth consumption.
Post by Diego Santos de Bem
How i can Call SRV Variable and puts it on path
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS) ?
INSTALL_PATH = Chr (34) & "\\SRV (Variable)\Agent\AgInstall.exe" & Chr (34)
FY = The SRV variable just contains the name of local server, do not contain \\
VBscript
' Variable Declarations
'==================================
Dim ipAddress, agentVersion, dataPath, xmlDoc, ElemList, regExist
Dim REQUIRED_AGENT_VERSION
Dim REQUIRED_SERVER_IP
Dim INSTALL_PATH
Dim STR_PARAMETERS
Dim FULL_INSTALL_PATH
'======================================
' MUST CHANGE VARIABLES IN THIS SECTION
'======================================
REQUIRED_AGENT_VERSION="4.6.0"
REQUIRED_SERVER_IP="192.168.1.100:12300"
INSTALL_PATH = Chr(34) & "\\Server\NETLOGON\AgInstall.exe" & Chr(34)
STR_PARAMETERS = " /FORCEINSTALL /INSTALL=AGENT /INSTDIR=" & Chr(34) &
"%PROGRAMFILES%\Framework\" & Chr(34) & " /SILENT"
Post by Diego Santos de Bem
FULL_INSTALL_PATH = (INSTALL_PATH & STR_PARAMETERS)
'======================================
' END CHANGE VARIABLES SECTION
'======================================
Const HKEY_LOCAL_MACHINE = &H80000002
CheckRegExist()
If (regExist=TRUE) Then
'==================================
' Get Registry Values
'==================================
agentVersion = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Agent Version: " & agentVersion
dataPath = ReadReg("HKEY_LOCAL_MACHINE\SOFTWARE\Network\Framework\Data Path")
'WScript.Echo "Data Path: " & dataPath
'==================================
' Read XML Sitelist
'==================================
Set xmlDoc = CreateObject("Msxml2.DOMDocument")
xmlDoc.load(dataPath & "\SiteList.xml")
Set ElemList = xmlDoc.getElementsByTagName("SpipeSite")
ipAddress = ElemList.item(0).getAttribute("ServerIP")
' MsgBox ipAddress & " " & InStr(REQUIRED_SERVER_IP,ipAddress)
'==================================
' Check Agent Version, ServerIP
'==================================
IF (agentVersion<REQUIRED_AGENT_VERSION) OR
InStr(REQUIRED_SERVER_IP,ipAddress) < 1 THEN
Post by Diego Santos de Bem
InstallNewAgent(FULL_INSTALL_PATH)
'MsgBox("Your agent is now up to date and configured correctly.")
ELSE
'MsgBox("Your agent is currently up to date and configured correctly.")
END IF
'Install Agent if Reg Does NOT exist
ELSE
InstallNewAgent(FULL_INSTALL_PATH)
END IF
'==================================
' Registry Reader
'==================================
Function ReadReg(RegPath)
Dim objRegistry, Key
Set objRegistry = CreateObject("Wscript.shell")
Key = objRegistry.RegRead(RegPath)
ReadReg = Key
End Function
'==================================
' Agent Installation
'==================================
Function InstallNewAgent(FULL_INSTALL_PATH)
Dim wshShell
Set wshShell = WScript.CreateObject ("WSCript.shell")
' MsgBox("Installing New Agent...")
wshshell.run FULL_INSTALL_PATH, 6, True
set wshshell = nothing
End Function
'==================================
' Check if Reg Key Exists
'==================================
Function CheckRegExist ()
Dim strComputer, objRegistry, strKeyPath, strValueName, strValue
strComputer = "."
Set objRegistry = GetObject("winmgmts:\\" & strComputer &
"\root\default:StdRegProv")
Post by Diego Santos de Bem
strKeyPath = "SOFTWARE\Network\Shared Components\Framework"
strValueName = "Version"
objRegistry.GetStringValue
HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
Post by Diego Santos de Bem
If IsNull(strValue) Then
'Wscript.Echo "The registry key does not exist."
regExist=FALSE
Else
'Wscript.Echo "The registry key exists. (" & strValue & ")"
regExist=TRUE
End If
End Function
Hello all!

Done with success!! Thank you!, now the validation of the installation of
the agent is not running always that run this script code it validates the
version of the agent installed if it is not the resent version of agent or
inexistent it starts Setup if already exists the script has to STOP and that
is not happening. could you help me? sorry guys really need help because i
dont know how to write, is a emergency and i will study later. thank you so
much

Loading...