According to this article, group policy is processed in descending order through the organization (ie start at forest, then domain, ou, etc). I have one GPO linked to the domain which runs a startup script to delete all mapped network drives; then I have various GPO's linked to OU's which map certain drives for certain groups. The problem is, the scripts which map the drives finish before the script which unmaps them! Can I fix this?
3 Answers
use Group Policy Preferences for drive maps (as Bryan commented). Much cleaner. I used it with XP, worked fine, now with Win 7 same. Logon scripts are so 2004.
Group policy is processed in order of link scope, yes. However, the 'processing' means determining which policies apply from which GPO, and which are overridden by a higher priority, more specific link, or enforce-mode GPO.
Startup scripts are not executed synchronously in the order of the GPO processing - they're not executed during the processing step at all. If you need to enforce a dependency order in your startup scripts, you'll need to do it in some other way.
As mentioned, clearing drive mappings before you apply them in the same script is a good option.
If you were really hurting, and you hate yourself, you could use "tasklist" in XP or 7 to find out if there are other CMD.EXE sessions running and "sleep" until they are done. I guess you could set the WINDOWTITLE in the domain script and search for it with something like:
tasklist /FI "IMAGENAME eq cmd.exe" /FI "WINDOWTITLE eq TESTING" /FO CSV
You'd have to loop over it with a few seconds sleep each time till it disappeared. Or you could just sleep for a minute and hope the other one doesn't take that long.
Makes me kinda ill to suggest it, though. ;-)
net use z: /d
,net use y: /d
,net use x: /d
, etc at the start of each logon script that maps the drives.