I have a VBScript that changes the IP address but it wont work inside the VM workstation (windows 10).
Has anybody done this before?
code:
***************************************************************
Set objShell = CreateObject("WScript.Shell")
objShell.Run "%COMSPEC% /k ipconfig"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colNetAdapters = objWMIService.ExecQuery _
("Select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
strAnswer = InputBox("Please enter your static IP Address:")
If TypeName(strAnswer) = "Empty" Then
WScript.Quit
End If
Wscript.Echo strAnswer
strIPAddress = Array(strAnswer)
strAnswer = InputBox("Please enter your Gateway Address (255.255.255.0):")
If TypeName(strAnswer) = "Empty" Then
WScript.Quit
End If
Wscript.Echo strAnswer
strSubnetMask = Array(strAnswer)
strAnswer = InputBox("Please enter your Gateway IP Address normaly close to your IP address:")
If TypeName(strAnswer) = "Empty" Then
WScript.Quit
End If
Wscript.Echo strAnswer
strGateway = Array(strAnswer)
strGatewayMetric = Array(1)
For Each objNetAdapter in colNetAdapters
errEnable = objNetAdapter.EnableStatic(strIPAddress, strSubnetMask)
errGateways = objNetAdapter.SetGateways(strGateway, strGatewaymetric)
If errEnable = 0 Then
WScript.Echo "The IP address has been changed."
Else
WScript.Echo "The IP address could not be changed. Try righ clicking and running with 'Elevated Privleges'"
End If
Next
**************************************************************************