-
-
' Script realizado por Anton Rodriguez Yuste para el establecimiento
-
' automatico de la IP y del nombre del PC
-
-
strComputer = "."
-
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
-
-
Set colNetAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
-
-
strIPAddress = Array("172.19.28.201")
-
strSubnetMask = Array("255.255.255.0")
-
strGateway = Array("172.19.28.1")
-
strGatewayMetric = Array(1)
-
-
For Each objNetAdapter in colNetAdapters
-
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
-
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
-
Next
-
-
RegKeyCompName = "HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\"
-
RegKeyTCPIP = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\"
-
Set WSHShell = CreateObject("WScript.Shell")
-
Set WSHShell = CreateObject("WScript.Shell")
-
NewName = "PC_201"
-
NewNameU = UCase(NewName)
-
NewNameL = LCase(NewName)
-
NewNameUCN = "CN=" & NewNameU
-
With WSHShell
-
.RegDelete RegKeyTCPIP & "Hostname"
-
.RegDelete RegKeyTCPIP & "NV Hostname"
-
.RegWrite RegKeyCompName & "ComputerName\ComputerName", NewNameU
-
.RegWrite RegKeyCompName & "ActiveComputerName\ComputerName", NewNameU
-
.RegWrite RegKeyTCPIP & "Hostname", NewNameL
-
.RegWrite RegKeyTCPIP & "NV Hostname", NewNameL
-
End With
-