All the script is supposed to do is get the ip address of the client and add .5 to the last octet passing this ip address through to remote desktop. It performs fine in XP but fails on a join error in 7 or 8. Any help?
' ************************************************************' SCRIPT to determine IP address of Terminal Server in Field installation
' ASSUMPTIONS: terminal device has been booted after DHCP server
' is operational. Calculation of server IP address is based
' on terminal device's IP address.
' PROCESSING:
' Obtain IP Address from Registry (NB: WMI doesn't work...)
'
' Compute server's IP Address by replacing own IP address's
' last octet with the number 5
'
' Invoke the TS client in fullscreen mode using the newly
' computed address
' When done with session, present MSGBOX -- otherwise, the TS
' session times out and restarts, leaving a bunch of sessions active
' ************************************************************
' VERSION:1.1
' DATE: September 6, 2007
' AUTHOR: Dom
' ************************************************************
' CHANGE LOG
' 1.0 Original, using registry hack
' 1.1 Modified to use WMI
' 1.2 May 2008 - Added msgbox
' 1.3 August 2008 - Translate msgbox
option explicit ' force all variables to be declared
' ************************************************************
' *** Start of script ***
' ************************************************************
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Dim WshShell, ObjNet
Dim StrComputer, Server
Dim objWMIService
Dim colItems, objItem
Dim strDefaultIPGateway, strIPAddress, strIPSubnet, cIPAddress
Set WshShell = WScript.CreateObject("WScript.Shell")
Set objNet=CreateObject("wscript.Network")
'Get the Computer's network name
strComputer=objNet.ComputerName
' Connect to root of management interface for this computer
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
strDefaultIPGateway = Join(objItem.DefaultIPGateway, ",")
strIPAddress = Join(objItem.IPAddress, ",")
strIPSubnet = Join(objItem.IPSubnet, ",")
exit for
Next
cIPAddress=split (strIPAddress,".",4)
Server = cIPAddress(0) & "." & cIPAddress(1) & "." & cIPAddress(2) & ".5"
WshShell.Run "%SystemRoot%\System32\mstsc.exe /v:" & server & " /f",,true
dim answer
answer = msgbox ("Click OK to log in to server, Cancel to terminate session" & vbcrlf & "Cliquez OK pour ouvrir une session sur le serveur, ou CANCEL pour fermer la session.",1 + 64 + 4096)
if answer = 1 then 'that would be "OK"
wshshell.run "wscript c:\windows\connect.vbs"
else
wshShell.run "shutdown -L"
end if
' ************************************************************
' END
' ************************************************************