Link to home
Start Free TrialLog in
Avatar of Fallbackpuppet
FallbackpuppetFlag for United States of America

asked on

Logon script not working correctly in Windows Server 2008 x64 TS

I have a client that needs their users to map back to their local c: drive as w: while logged into a terminal session.  I created an OU just for the terminal server then created a GP for it I set loop back to enable replace I then changed User Configuration/Administrative Templates/System/Scripts scripts synchronously to enable.  Lastly I added a logon script to the GPO.  It is a simple .bat file with one line as follows:

Net Use W: \\%ClientName%\C$

If I run this command as written manually from cmd on the TS it works fine even as a regular user.  If I enable this same script for any other computers in the domain it works perfectly.  However this script is not mapping the drive on the W2K8 x64 TS when you connect from a winXP computer.  However if you RDP from a vista machine the script correctly maps the drive.  When I put a pause in the file I can see that when it is not running correctly the CMD window shows the line as Net Use W: \\\C$ and that does not get us anywhere.  So how do I get the drives to map correctly from the windows xp computers on the 08 x64 terminal server?
Avatar of mrmarkfury
mrmarkfury
Flag of United States of America image

Why not include an if statement in your batch file that checks for XP machines, and when it finds an XP machine, uses %COMPUTERNAME% instead?
Avatar of Fallbackpuppet

ASKER

I thought that %computername% would produce the name of the terminal server and not the client machine but I will try it.
My mistake, didn't realize you were looking for the client's computer name
Have you tried remoting into a TS with an XP client, going to the command line, and typing "set". See if CLIENTNAME is populated with the correct value.
I have and it is.  this script works from either of the 2 vista workstations but not from any of the 25 xp workstations
I tried to change it to a vb script form .bat script as follows:

ON ERROR RESUME NEXT

Set oShell = CreateObject("WScript.Shell")
STRComputer = oShell.ExpandEnvironmentStrings("%Clientname%")
STRConnection = "\\" & STRComputer & "\C$"

Set WshNetwork = CreateObject("WScript.Network")

WshNetwork.RemoveNetworkDrive "W:"

WshNetwork.MapNetworkDrive "W:", STRConnection

however that gave me the same results as the .bat file
I'm guessing these clients on XP are using RDP, try updating the RDP client on one machine. I heard that there were certain builds that wouldn't pass %CLIENTNAME% properly.
We are working with RDP CLient 6.1 and I can not find a newer one that will run on XP.  Also when you run either script after the client is logged in even with an xp client machine they work fine.
Have you ensured no other Enforced policy is overriding the loopback ( I can't remember if loopback replace or enforce wins in a conflict)
I thought of that but the only other policy does nto differintiate between xp and vist but this works on vista.  So I do not think so but I will double check.
ASKER CERTIFIED SOLUTION
Avatar of Fallbackpuppet
Fallbackpuppet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tom_ide
tom_ide

This registry entry change also works for logon.bat files that do not complete when users logon to a W2008 Terminal Server. My situation was that we use generic logon.bat files that map drives to locations that individual users may not have permissions to. When users logon to our w2008 domain from workstations, the logon.bat script jumps invalid mappings and completes the drive mappings that users have permissions to. When logging onto a W2008 Terminal Server, the same logon.bat file stops and requests a user name and password for each drive mapping that the user does not have permissions for. This freezes the logon to the terminal server. Adding this registry entry allows the logon.bat to run the same on the terminal server as the network logon. Invalid drive mappings are ignored, and the remainder of the logon.bat runs to completion.