Jump to content

Group Policy Mapped Drive Script - Not Working


Recommended Posts

Posted

Hey Everyone,

 

This has been a problem for going on a year now. I've done a lot of research, but still can't find a solution to my problem. Here's the details:

 

We have a network with a little over 100 computer users. We have 5 sites and 5 DC's. We have a script file that maps drives to our servers (see attached at bottom). The file is attached to GPO's at user logon. The odd thing is, the script will run on about half of the computers and the other half they will not. I've linked these GPO's to the proper OUs. I have the GPO's applied to all "Authenticated Users". I set the Default Domain Policy to Enforced and set the Script Policy Processing to Enabled and selected the allow script policy to run over slow connections and process policy even if no changes have occurred. I also changed the value of the slow link detection to 0, which should have disabled it. I have the script in the right location on the server. I've tried gpupdate /force on the computers that don't have the script run. I added a system pause in the script for 20 seconds to ensure the network connections have been fully initialized after logon, before trying to map the drives. I have absolutely no clue what to try next. Can someone please help?

 

Script File:

 

' mapdrive.vbs

' VBScript to map network drives

' -------------------------------------------'

'

Option Explicit

Dim objNetwork, strDrive, objShell, objUNC

Dim strRemotePath1, strDriveLetter1, strNewName1, strRemotePath2, strDriveLetter2, strNewName2, strRemotePath3, strDriveLetter3, strNewName3, strRemotePath4, strDriveLetter4, strNewName4, strRemotePath5, strDriveLetter5, strNewName5, strRemotePath6, strDriveLetter6, strNewName6

Dim bForce, bUpdateProfile, strRemDriveLetter

 

WSCript.Sleep 20000

 

 

' This section removes any existing mapped drives, begining at the letter "J:"'

' if no drive exists, the script moves to the next drive letter'

' --------------------------------------------------------------------------- '

strRemDriveLetter = "G:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "H:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "I:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "J:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "K:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "L:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "M:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "N:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "O:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "P:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "Q:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "R:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "S:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "T:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "U:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "V:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "W:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "X:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "Y:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

strRemDriveLetter = "Z:"

err.number = vbempty

Set objNetwork = CreateObject("WScript.Network")

' Removes strRemDriveLetter, with bForce, pUpdate Profile

On Error Resume Next

objNetwork.RemoveNetworkDrive strRemDriveLetter, _

bforce, bUpdateProfile

 

 

' This section of the script maps the desired drives to directories '

' ----------------------------------------------------------------- '

 

strDriveLetter1 = "R:"

strRemotePath1 = "\\reg-fs1\thrasher"

strNewName1 = "REG-Clarksburg \ General"

strDriveLetter2 = "M:"

strRemotePath2 = "\\reg-thrashenv1\thrashenv"

strNewName2 = "REG-Charleston \ General"

strDriveLetter3 = "N:"

strRemotePath3 = "\\reg-Potomac1\potomac"

strNewName3 = "REG-Oakland \ General"

strDriveLetter4 = "O:"

strRemotePath4 = "\\reg-Berkeley1\berkeley"

strNewName4 = "REG-Martinsburg \ General"

strDriveLetter5 = "P:"

strRemotePath5 = "\\reg-Pentree1\pentree"

strNewName5 = "REG-Pentree \ General"

strDriveLetter6 = "Q:"

strRemotePath6 = "\\reg-fs1\thrasher\acct"

strNewName6 = "REG-Clarksburg \ Accounting"

 

 

' Section to map the network drive

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter1, strRemotePath1

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter2, strRemotePath2

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter3, strRemotePath3

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter4, strRemotePath4

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter5, strRemotePath5

Set objNetwork = CreateObject("WScript.Network")

objNetwork.MapNetworkDrive strDriveLetter6, strRemotePath6

 

 

' Section which (re)names the Mapped Drive

' To undo the naming, editing the registry is required

' launch regedit; the value turns up under MountPoints. The full path is:

' HKCU, Software, Microsoft, Windows, CurrentVersion, Explorer, MountPoints2,

' The Reg_SZ was called _LabelFromReg. My advice is to just delete the value - leave it blank.

' The result will be that future drive mapping will revert to the traditional style of mapping.

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter1).Self.Name = strNewName1

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter2).Self.Name = strNewName2

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter3).Self.Name = strNewName3

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter4).Self.Name = strNewName4

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter5).Self.Name = strNewName5

Set objShell = CreateObject("Shell.Application")

objShell.NameSpace(strDriveLetter6).Self.Name = strNewName6

 

 

' Echo for check

Wscript.Echo "Mapped drive '" & strNewName1 & "' has been changed from L: to " & strDriveLetter1

WScript.Quit

Posted

Hi,

 

How do you know the script does not run?

 

it runs silently, yes? maybe you need to put in something visual to prove that it runs or not.

 

MsgBox "Yup it runs!"

 

perhaps manually map some drives and see if the script removes them.

 

i am guessing that the script runs but cannot map the drives, cannot see the path?

 

BoX

Posted

Thanks for replying.

If you'll note the bottom of the script file, I have a dialog box pop up with a message.

 

The users who don't have their drives mapped also don't get the dialog box.

Thanks

Posted
doh!

my bad for not reading to the end.

:o

 

No problem, I'm just happy to know people are trying to help :)

This has been a major problem for a while. :confused:

Posted
Yes. The script will actually deploy to about half of the computers with no problems.

 

 

The ones it works on, are those computers older than the others?

Posted
I mean hardware specifications. The computers is does work on, are the specifications of those lower than the ones that don’t work?
Posted

Are all the machines that dont work in the same ou? or are they spread across all OU's?

 

I've had a few issues on old systems that wouldn't pickup GPO's untill i did

ipconfig /flushdns

then ran gpupdate /force

 

also make sure your logged in as a domain admin not a local user when doing gpupdate

Posted

can you try calling them from a login script instead of from the group policy?

 

maybe some machines need a longer delay due to different NICs or have a slower connection.

Posted

If you deploy any software by MSI does it also have issues with these machines. If so it could be windows not waiting for the cards to be fully connected and procesding without applying network configuration stuff. There are two fixes for this the first is to apply this registery change which is recommended here.

 

The next is to make sure that Spanning tree protocol - Wikipedia, the free encyclopedia is set up to only have a short delay for all client computer ports because this also causes windows to go on ahead when it gets impatient.

Posted

Hey guys thanks for the replies!

 

The problem seems to occur on both old and new computers, but mainly the older ones.

 

Yes, they're in the same OU and yes, I've had a tech logged in as a domain admin while doing gpupdate /force. I'll try the ipconfig /flushdns

 

I've disabled the slow link detection, so I don't think slow connections would be causing the problem... not sure though. I'll try loading the script via AD

 

All MSI packages deploy fine. In fact, I think all computer settings apply to all computers, but the user settings (where i have the logon script) doesn't get applied to some.

 

Thanks guys

Posted
Adding the script to the "logon script" section in AD seems to work fine. However, this isn't a viable option for all 50 employees, as it will take too long to add the file to each user it's not working for. Any other ideas?
Posted

You can change the details of multiple users in AD, at the same time, if you select them all and then right-click.

 

...This won't solve your problem of course..

 

I had found that some machines had issues with loading GPOs if they had the older version of the network driver, it seemed to be reconnecting the card in windows, at the same time windows was trying to load the GPOs. Check to see if you have the most recent versions.

 

Do you get any errors in the client eventlogs ?

Posted
You can change the details of multiple users in AD, at the same time, if you select them all and then right-click.

 

...This won't solve your problem of course..

 

I had found that some machines had issues with loading GPOs if they had the older version of the network driver, it seemed to be reconnecting the card in windows, at the same time windows was trying to load the GPOs. Check to see if you have the most recent versions.

 

Do you get any errors in the client eventlogs ?

 

This can be a problem with some of the SIS chip sets.

Have you tried running a shorter version of the script?

Once you do get it working as well you could shorten that script a lot using some kind of loop as you are repeating the same code over and over.

Posted

We had this problem a while ago with some of the older/poorer spec machines running vbscript.

I think that the vbenginge was loading after the script was started [obviously the script will fail].

We moved over to kix scripts and all was ok.

Posted (edited)

Can you run the script manually when the user is already logged in and you know the network connection has sparked to life and see that it works?

 

Add a few pauses to your script and run it visibly so you can see it's results while you do this.

 

Can you think of anything these machines have in common that the successful ones don't (I'm thinking have they been imaged recently EDIT (well not so much recently but at the same time or using the same image) or is there some other policy over-riding them), you said you have multiple DC's - do they all run AD and have you been to the default domain policy for all of them.

 

Do all the successful machines reside in the same OU(s) if so have you tried putting some of the unsuccessful ones in that(those) OU's?

 

It could also be worth trying to delete one of the machines computer accounts in AD, disconnect and then rejoin it to the domain and move the account created back into the right OU.

 

You've probably tried all this though!

Edited by superfletch
Adjustment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...