Why won't my logon scripts map drives under Windows 7?

I'm using a VBScript script similar to the one below. The script runs using a group policy.

Dim WshNetwork
Set WshNetwork = WScript.CreateObject("WScript.Network")

WshNetwork.MapNetworkDrive "g:", "\\\Saturn\data\"
WshNetwork.MapNetworkDrive "k:", "\\\Saturn\stuff\"

It works fine for Windows XP.

Update: Copying the script locally and running it runs fine, so I suspect the Group Policy isn't running the script on Windows 7.

  • I have exactly the same problem but with Vista and Windows 7 x64, x32 versions are fine across XP, Vista and Windows 7. – Richard Slater Dec 17 '09 at 16:36

With UAC enabled you cannot map drives in a logon script that is assigned using a Group Policy Object (GPO). The GPO logon script does run, but under a different security context, so the mappings get lost.

Microsoft provides a sample script, called launchapp.wsf that works around this problem by running your real logon script a moment later under the correct security context.

It is available here: http://technet.microsoft.com/en-us/library/cc766208(WS.10).aspx

Look for the section titled “Group Policy Scripts can fail due to User Account Control” and also Appendix A, which is the source code for launchapp.wsf.

launchapp.wsf does fix the problem of mapping drives on Vista (and Windows 7) PCs that have UAC enabled. However, it causes another problem: it doesn't work in Windows XP, so XP computers show an error instead of running the logon script.

Fortunately XP computers don't need the launchapp hack, so my company made a modified version of launchapp that tries to do things the Vista way, but if that fails (because you're running XP), it just launches the real logon script straightaway. I can’t share this with you as it’s internal to my company (has real server names etc.) but it wasn’t too hard to do.


Probably not a good idea to use that EnableLinkedConnections registry setting - Microsoft specifically point out in that KB that it's unsupported - it's bound to give you grief later. I've written up a solution here: http://pcloadletter.co.uk/2010/05/15/missing-network-drives/

  • 1
    +1 for coherent and comprehensible description of the problem in the linked post – Martin Sep 20 '10 at 6:38

I strongly suspect that your script is running fine.

I'm betting your users are Administrators, and because you have User Account Control enabled the users' filtered token, under which Explorer runs, doesn't have access to the "drives" that were "mapped" when the logon script ran.

If you're not going to use Group Policy Preferences then you have two choices:


That exact script you created works fine for me on Windows 7, as long as I make the initial backslash into a double. So that you try and map \\saturn\data. (Use backticks to preserve your code formatting.)

Does this script generate any errors when you run it by double clicking, instead of as a startup script?

  • Hi, I had put two \\ backslashes in when I typed the question but the site on shows one, I've now put three in and it formats correctly. I've updated my post as I now suspect the Group Policy is to blame. – Steven Dec 18 '09 at 9:45

I suspect the missing slash as well, however I would recommend abandoning the script as long as you have one Windows 7 /Windows Vista/Windows Server 2008 machine you now have access to use group policy preferences.

You will need to install the preferences client via Windows Update on all workstations, but it makes mapping drives much easier than scripting them. This article is a great summary (better than the one on technet) about how to go about it:

Group Policy Preferences in a Windows 2003 Domain (and a Windows 2008 Domain)

As another aside I've never been fond of mapping drives since Windows XP (yes, I know sometimes you have to). You should also consider beginning to educate the users about how to add favorite network locations to the OSes. The libraries feature on Windows 7 makes this particularly easy, and once set up, I've found that most users prefer it to mapped drives after they get over their initial resistance).

  • GPPs are awesome! Save so much time and scripting. – joshperry Jan 21 '11 at 19:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.