quark122
asked on
Group Policy Logon script
Hi,
I just installed Windows 2003 Enterprise and have 2 workstations connected to it. I'm trying to set up a group policy logon script to map a few network drives.
I tried doing just a drives.cmd with net use j: \\server\share and then adding drives.cmd to the group policy logon script but that doesn't seem to work.
I have a .vbs version with the proper vbs command (don't have access to it at the moment), which works if I place it in the login script field of each user's profile, but fails if I copy it to the proper folder & add it to the group policy logon script window.
Can somebody help?
I just installed Windows 2003 Enterprise and have 2 workstations connected to it. I'm trying to set up a group policy logon script to map a few network drives.
I tried doing just a drives.cmd with net use j: \\server\share and then adding drives.cmd to the group policy logon script but that doesn't seem to work.
I have a .vbs version with the proper vbs command (don't have access to it at the moment), which works if I place it in the login script field of each user's profile, but fails if I copy it to the proper folder & add it to the group policy logon script window.
Can somebody help?
Sounds like some troubleshooting is needed. Maybe put a net send command with a message to send out. This way you will know if the .cmd file is at least running. Does it work for an administrator? Have to narrow down where the problem is first. Is the group policy being applied?
Quark,
When you say you're adding this to the group policy, are you adding it under machine policy or user policy? should be added under user policy.
kris.
When you say you're adding this to the group policy, are you adding it under machine policy or user policy? should be added under user policy.
kris.
ASKER
Yes, I'm adding it under user policies (that's where the logon/logoff script policy entries are under?)
What GPO are you modifying?
It should be the Default Domain Policy, not the Default Domain Controller Policy.
It should be the Default Domain Policy, not the Default Domain Controller Policy.
the clients are windows 2000 or above, right?
ASKER
Both are Windows XP Professional clients, and both log onto the domain.
It is in the Default Domain Policy.
It is in the Default Domain Policy.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Well, it seems to be working now...
Here's where I have the command file:
In the Group Policy Editor: Default Domain Policy\Windows Settings\Scripts (Logon/Logoff)\Logon
\\domain\sysvol\domain\Pol icies\{31B 2F340-016D -11D2-945F -00C04FB98 4F9}\User\ Scripts\Lo gon
is the location of my command files
drives.cmd
net use j: \\server\share\folder
Thanks to all... how do I share points among the folks?
Netman66 - I had it (for a brief time) in SYSVOL\{domain}\scripts & in the logon for the user (under ad, user, profiles), but that's awfully inconvenient if I want to apply something to all users. I removed it from there when it appeared that the .cmd file was working. As a vbs, though, it still doesn't work.
wshNetwork.MapNetworkDrive "j:", "\\server\share\folder"
It doesn't like wshNetwork?
Here's where I have the command file:
In the Group Policy Editor: Default Domain Policy\Windows Settings\Scripts (Logon/Logoff)\Logon
\\domain\sysvol\domain\Pol
is the location of my command files
drives.cmd
net use j: \\server\share\folder
Thanks to all... how do I share points among the folks?
Netman66 - I had it (for a brief time) in SYSVOL\{domain}\scripts & in the logon for the user (under ad, user, profiles), but that's awfully inconvenient if I want to apply something to all users. I removed it from there when it appeared that the .cmd file was working. As a vbs, though, it still doesn't work.
wshNetwork.MapNetworkDrive
It doesn't like wshNetwork?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try this script to map multiple drives without having to fully understand VBScript:
' ########################## ########## ########## ########## ########## ######
' Written in VBScript.
' Paul DeBrino .:. www.infinity-rd.com .:. March 2004.
' Establishes map drives.
' Assign to OU Group Policy under USER CONFIG, WINDOWS SETTINGS, SCRIPTS, LOGON SCRIPT.
'
' This script will:
' (1) check if the drive is already connected and, if so, disconnect it.
' (2) map the drive.
'
' Arguments are as follows:
' MAPIT DRIVE-LETTER as string, PATH as string, USER as string, PASSWORD as string
' (1) Do not specify colon in drive letter.
' (2) Do not end path with a forward slash.
' (3) If user and password are not required to establish map, then specify a zero-length string as follows: ""
'
' Reference Microsoft info at:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthmapnetworkdrive.asp
' ########################## ########## ########## ########## ########## ######
' Create the Shell or environment for the commands:
Set WshShell = WScript.CreateObject("WScr ipt.Shell" )
' Define objects:
Set WshNetwork = WScript.CreateObject("WScr ipt.Networ k")
Set oDrives = WshNetwork.EnumNetworkDriv es()
' ========================== ==========
' DEFINE WHO TO CONTACT for pop-up messages:
' ========================== ==========
strContactMessage = "If you require assistance, please contact IT Support."
' ==================
' DEFINE DRIVES TO MAP:
' ==================
Mapit "M", "\\server1\public", "", ""
Mapit "P", "\\server2\public", "", ""
Mapit "Q", "\\imageserver\public", "imageuser", "imagepwd"
' ========
' CLEAN UP:
' ========
Set WshShell = Nothing
Set WshNetwork = Nothing
Set oDrives = Nothing
' ########################## ########
' DO NOT MODIFY ANYTHING BELOW THIS POINT...
' unless you are familiar with the proper settings.
' ########################## ########
Sub Mapit(strLetter, strPath, strUser, strPass)
' Define the DriveLetter:
DriveLetter = strLetter & ":"
' Define the remote path:
RemotePath = strPath
' Pop-up Notices (set to False to disable notices, otherwise set to True):
bPopReminder = True
' Define known errors to trap:
Dim arrErrCode(1)
Dim arrErrDesc(1)
arrErrCode(0) = -2147023694
arrErrCode(1) = -2147024811
arrErrDesc(0) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to a previously defined remembered map with the same letter." _
& vbCrLf & vbCrLf & "Please MANUALLY disconnect map drive " & DriveLetter _
& ", then Log Out and Log back in."
arrErrDesc(1) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " since " & DriveLetter & ": was previously reserved by your computer." _
& vbCrLf & vbCrLf & "(Refer to Management, Shared Folders, Shares)"
' Define whether the map information should be removed from the current user's profile:
bForceRemoveFromProfile = True
bRemoveFromProfile = True
' Define whether the map information should be stored in the current user's profile:
bStoreInProfile = False
' Check if already connected:
AlreadyConnected = False
For i = 0 To oDrives.Count - 1 Step 2
If LCase(oDrives.Item(i)) = LCase(DriveLetter) Then AlreadyConnected = True
Next
' Attempt to map the drive. If already mapped, first attempt disconnect:
If AlreadyConnected = True then
WshNetwork.RemoveNetworkDr ive DriveLetter, bForceRemoveFromProfile, bRemoveFromProfile
If Not strUser = "" Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " disconnected, then connected successfully to " & RemotePath
Else
On Error Resume Next
If Not strUser = "" Then
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile, strUser, strPass
Else
WshNetwork.MapNetworkDrive DriveLetter, RemotePath, bStoreInProfile
End If
If Err.Number <> 0 Then
bKnownError = False
For I = LBound(arrErrCode) To UBound(arrErrCode)
If Err.Number = arrErrCode(I) Then
bKnownError = True
strPopMessage = arrErrDesc(I)
' Display the Disconnect Network Drives window:
If Err.Number = arrErrCode(0) Then
Set objWSH = Wscript.CreateObject("WScr ipt.Shell" )
objWSH.Run "rundll32.exe shell32.dll,SHHelpShortcut s_RunDLL Disconnect", 1, true
End If
Exit For
End If
Next
If Not bKnownError Then
strPopMessage = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to reason stated below."
End If
' Display warning message:
strPopMessage = "WARNING!! WARNING!! WARNING!! WARNING!!" _
& vbCrLf & vbCrLf & strPopMessage _
& vbCrLf & vbCrLf & Err.Description & " (error " & Err.Number & ")" _
& vbCrLf & vbCrLf & strContactMessage
WshShell.PopUp strPopMessage
Else
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " connected successfully to " & RemotePath
End If
End If
' Release resources:
Set objWSH = Nothing
' Slight pause to ensure each pass has time to commit:
wscript.sleep 200
End Sub
' ##########################
' Written in VBScript.
' Paul DeBrino .:. www.infinity-rd.com .:. March 2004.
' Establishes map drives.
' Assign to OU Group Policy under USER CONFIG, WINDOWS SETTINGS, SCRIPTS, LOGON SCRIPT.
'
' This script will:
' (1) check if the drive is already connected and, if so, disconnect it.
' (2) map the drive.
'
' Arguments are as follows:
' MAPIT DRIVE-LETTER as string, PATH as string, USER as string, PASSWORD as string
' (1) Do not specify colon in drive letter.
' (2) Do not end path with a forward slash.
' (3) If user and password are not required to establish map, then specify a zero-length string as follows: ""
'
' Reference Microsoft info at:
' http://msdn.microsoft.com/library/default.asp?url=/library/en-us/script56/html/wsmthmapnetworkdrive.asp
' ##########################
' Create the Shell or environment for the commands:
Set WshShell = WScript.CreateObject("WScr
' Define objects:
Set WshNetwork = WScript.CreateObject("WScr
Set oDrives = WshNetwork.EnumNetworkDriv
' ==========================
' DEFINE WHO TO CONTACT for pop-up messages:
' ==========================
strContactMessage = "If you require assistance, please contact IT Support."
' ==================
' DEFINE DRIVES TO MAP:
' ==================
Mapit "M", "\\server1\public", "", ""
Mapit "P", "\\server2\public", "", ""
Mapit "Q", "\\imageserver\public", "imageuser", "imagepwd"
' ========
' CLEAN UP:
' ========
Set WshShell = Nothing
Set WshNetwork = Nothing
Set oDrives = Nothing
' ##########################
' DO NOT MODIFY ANYTHING BELOW THIS POINT...
' unless you are familiar with the proper settings.
' ##########################
Sub Mapit(strLetter, strPath, strUser, strPass)
' Define the DriveLetter:
DriveLetter = strLetter & ":"
' Define the remote path:
RemotePath = strPath
' Pop-up Notices (set to False to disable notices, otherwise set to True):
bPopReminder = True
' Define known errors to trap:
Dim arrErrCode(1)
Dim arrErrDesc(1)
arrErrCode(0) = -2147023694
arrErrCode(1) = -2147024811
arrErrDesc(0) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to a previously defined remembered map with the same letter." _
& vbCrLf & vbCrLf & "Please MANUALLY disconnect map drive " & DriveLetter _
& ", then Log Out and Log back in."
arrErrDesc(1) = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " since " & DriveLetter & ": was previously reserved by your computer." _
& vbCrLf & vbCrLf & "(Refer to Management, Shared Folders, Shares)"
' Define whether the map information should be removed from the current user's profile:
bForceRemoveFromProfile = True
bRemoveFromProfile = True
' Define whether the map information should be stored in the current user's profile:
bStoreInProfile = False
' Check if already connected:
AlreadyConnected = False
For i = 0 To oDrives.Count - 1 Step 2
If LCase(oDrives.Item(i)) = LCase(DriveLetter) Then AlreadyConnected = True
Next
' Attempt to map the drive. If already mapped, first attempt disconnect:
If AlreadyConnected = True then
WshNetwork.RemoveNetworkDr
If Not strUser = "" Then
WshNetwork.MapNetworkDrive
Else
WshNetwork.MapNetworkDrive
End If
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " disconnected, then connected successfully to " & RemotePath
Else
On Error Resume Next
If Not strUser = "" Then
WshNetwork.MapNetworkDrive
Else
WshNetwork.MapNetworkDrive
End If
If Err.Number <> 0 Then
bKnownError = False
For I = LBound(arrErrCode) To UBound(arrErrCode)
If Err.Number = arrErrCode(I) Then
bKnownError = True
strPopMessage = arrErrDesc(I)
' Display the Disconnect Network Drives window:
If Err.Number = arrErrCode(0) Then
Set objWSH = Wscript.CreateObject("WScr
objWSH.Run "rundll32.exe shell32.dll,SHHelpShortcut
End If
Exit For
End If
Next
If Not bKnownError Then
strPopMessage = "Unable to map drive " & DriveLetter & " to " & RemotePath _
& " due to reason stated below."
End If
' Display warning message:
strPopMessage = "WARNING!! WARNING!! WARNING!! WARNING!!" _
& vbCrLf & vbCrLf & strPopMessage _
& vbCrLf & vbCrLf & Err.Description & " (error " & Err.Number & ")" _
& vbCrLf & vbCrLf & strContactMessage
WshShell.PopUp strPopMessage
Else
If bPopReminder Then WshShell.PopUp "Drive " & DriveLetter & " connected successfully to " & RemotePath
End If
End If
' Release resources:
Set objWSH = Nothing
' Slight pause to ensure each pass has time to commit:
wscript.sleep 200
End Sub
If you are looking to map drives faster and not having to wait the time you should try SCRIPTLOGIC, this software has saved me so much time that could not even begin to count. check it out here at SCRIPTLOGIC.COM if you have any questions abour feel free to e-mail me about it at <email address removed by sirbounty - page editor>
I am trying to use GPO to force a standardized wallpaper to my users. It works for the most part except I have two machines that will not take the wallpaper, I can see the GPO took effect because they can't change from the standard blue wallpaper they are now getting. Anybody have any ideas?
Brian
Brian
I"m just wondering...this might be so obvious you overlooked it...I believe the image being used for the wall paper needs to be on the local machine...is it?
Jonathan
Jonathan
bboett:
What you need to do is create a folder (call it whatever you want, Wallpaper, on your DC, share it with read permissions, place your BMP file in it.
go to gpo/User Configuration/ Administrative Templates / Desktop / Active Desktop / Active Desktop Wallpaper.
Do yourself a BIG favor, read the Explain info for this, it basically tells you step by step how to enable this feature. I use it for my Elementary school student users as their wallpaper.
What you need to do is create a folder (call it whatever you want, Wallpaper, on your DC, share it with read permissions, place your BMP file in it.
go to gpo/User Configuration/ Administrative Templates / Desktop / Active Desktop / Active Desktop Wallpaper.
Do yourself a BIG favor, read the Explain info for this, it basically tells you step by step how to enable this feature. I use it for my Elementary school student users as their wallpaper.
CrimeScene, great job, this vbscript, really
thanks and regards
thanks and regards
how to reset administrator password in win xp pro sp-2