Hello All,
My name is Diego and 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, so need to get the download installation file on the local serverr, 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 that the installation path of the file is correct to all offices, each office has a local server defined on Windows XP variable System :
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