net use in logon script not taking effect
I wrote a logon script that launches a PowerShell script that uses "net use" to replace drives mapped to an old server*. On Windows XP, this script runs correctly, and the new drives are visible and correct. However, on Windows 7, even though "net use" shows that it ran correctly, the old drives are still there in Explorer. If I log off and on a second time, then those drives are replaced as intended. The strange thing is that if I run the logon script manually, then the drives update immediately. Why, during the logon script, do the drives not replace until logoff? One more thing, before logoff, I check the WMI win32_networkconnection, and I see double drives (two with the same letter), one with the old path, and one with the new path. How can I get rid of the old ones entirely without having to log off and on again? Please let me know if you have any questions. -join("526f6765725365656b656c6c"-split"(?<=\G[^\n]{2})",12|%{[char][int]"0x$_"}) *- I don't know whether there are mapped drives or not, or what letters, so I need the script to find network drives mapped to the old server.
July 18th, 2012 4:13pm

This is by design. Rgds Milos
Free Windows Admin Tool Kit Click here and download it now
July 18th, 2012 4:19pm

In that case, would you please share a few scenarios where this design would make sense? It confuses me.
July 18th, 2012 4:35pm

Hi, I would like to suggest that you initiate a new thread in our Scripting forum for better and accurate answer to the question. The community members and support professionals there are more familiar with Scripting and can help you resolve the issue. Thanks. http://social.technet.microsoft.com/Forums/en-us/category/scripting The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding. Hope this helps Vincent Wang TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
July 19th, 2012 3:50am

At last, I think that I found an explanation of the situation. Here are three links that made sense: http://support.microsoft.com/kb/937624 http://think-like-a-computer.com/2011/06/16/login-scrips-fail-map-drives/ http://technet.microsoft.com/en-US/library/5ae8da2a-878e-48db-a3c1-4be6ac7cf763.aspx (the heading "Group Policy Scripts can fail due to User Account Control") The short answer is that administrator accounts in Windows starting with Vista have two contexts, one Administrator and one not, and mapped drives live in only one. The user sees the "not admin" context in My Computer and other places, but running cmd or PowerShell as administrator, one sees the drives of the admin context, usually a different set of drives. A logon script applies to the administrator context, and not the "not admin" context, until logoff/on. (A non-admin user has only one context, so a logon script maps drives as expected.) The solution presented in the third link was basically to run the logon script as a scheduled task, which runs as "not admin" unless specified. I did so, and it solved my problem. P.S. If I had received some information about the design I was encountering, or potential solutions, something related to or including the above, then I would have appreciated that post and marked it as helpful, if not the answer.
July 20th, 2012 5:01pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics