Windows – NETLOGON scripts not being executed

logon-scriptswindowswindows-sbs

Each user on our new domain needs to have drives mapped according to a batch file. The problem is, I have a GPO rule set to execute the following command on all domain logins:

\\servername\netlogon\%username%.bat

Executing this after the session has started works, but for some reason it wont automatically map the drives as outlined in the batch file. I have also put the login scripts in the default folder "\WINDOWS\sysvol\sysvol\domain.name{GUID}\User\Scripts\Logon" with the following command to be executed:

logon.bat

which contains an entry to run %username%.bat, and this does not work either. I am running Windows SBS 2011. Any ideas?

Thanks,
Alex

Best Answer

The first way you tried, specifying the script name with "%username%" in it probably won't fly. I'm fairly certain that environment variable expansion inside the "Scripts" Group Policy Client Side Extension (CSE) won't work. I don't have any documentation that says one way or the other, but I'd find it highly dubious.

The second way you're trying, calling a "logon.bat" from the CSE and, in that script, calling "%username%.bat" should work, provided you can get the path to "%username%.bat" right. I'd call it like so:

call %0\..\%username%.bat

That ought to get the "%username%.bat" file located in the same directory as the "logon.bat" script to execute.

Finally, be sure that your users don't have "Administrator" rights if you're running Windows Vista or Windows 7 on your client computers. If you are, and they do, then drives that are "mapped" during the logon script won't be visible in Explorer by default. (You can get some background on that here: Networkmapping script (VBS) Vista doesn't work, XP does)