|
|
![]() |
|
|
Top | #1 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Was wondering if I can setup SBS2003 to assign mapped drives to workstations instead of me going around manually mapping them from each workstation? Thanks, Heeter |
|
|
|
|
|
Top | #2 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
use a login script, assign the login script to the user accounts
|
|
|
|
|
|
Top | #3 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Thanks Fitz,
would you know of a copy that I can find of this logon script that I could use as a template? Since it is a script, I am presuming that it is a .bat file, am I correct? Thanks, Heeter |
|
|
|
|
|
Top | #4 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
you can use either batch or VBScript/WSH (windows Script Host) - technically, you can also use KIX and some other ones too..
in Batch: net use <drive letter> <share path> Code:
net use z: \\server1\shareMe Code:
set objNet = CreateObject("wscript.Network")
objNet.MapNetworkDrive "z:","\\server1\shareMe"
Since I prefer VBScript, you can copy my script below and hack it up for your needs. It does some minor error checking.. Code:
set objNet = CreateObject("Wscript.Network")
set objFSO = CreateObject("Scripting.FileSystemObject")
strPath = "\\server1\shareName"
strDriveLetter = "z:"
'checks to see if the drive letter is already mapped
if not ( objFSO.DriveExists(strDriveLetter) ) then
'drive is not mapped, so just map the drive and we're done
objNet.MapNetworkDrive strDriveLetter,strPath
else
'if the drive is already mapped, check to see if it is mapped to the correct share
'if the drive is mapped correctly, nothing to do
'if the drive is mapped to a different share, disconnect the share and map correctly
set objDrive = objFSO.GetDrive(strDriveLetter)
if not (objDrive.ShareName = strPath) then
objNet.RemoveNetworkDrive strDriveLetter,true,true
objNet.MapNetworkDrive strDriveLetter,strPath
end if
end if
edit: and madmatt.. piss off and stop bugging me in IM to post a script
|
|
|
|
|
|
Top | #5 |
|
Bow Down to the King
Joined: April 2002
Location: New York
Posts: 13,312
Reputation: 4090
Power: 294 |
Just making sure you fulfill your duties as a moderator and master scripter. =)
|
|
|
|
|
|
Top | #6 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Awesome, thanks for the template!!!!!!
Should I go around and disconnect the existing mapped drives? With this setup, I will presume that I can create a different vbscript for each drive that I would like to map, would this be correct? saving this file would be *.vbs, like in my situation it would be datadrive.vbs and specdrive.vbs, etc, etc? Thanks again for all your help. Heeter |
|
|
|
|
|
Top | #7 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
|
|
|
|
|
|
Top | #8 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
Originally Posted by Heeter
well, I like to do it to make sure my users are all connected to the correct drives as some of them got into the habit of remapping drives. The script snippet I wrote will automagically disconnect the drive if the drive letter that you are trying to map correctly is in use.
basically, no - you don't create seperate scripts for each drive. The user account properties will only accept a single login script file (although, technically I suppose you could create seperate vbs files and call them through a bat file and have the bat file as your one login script. But, generally, you'll wrap it into one file. You could remove the variables (strDriveLetter and strPath) and use the actual string values and write multiple connect lines like: Code:
objNetwork.MapNetworkDrive "y:","\\server\share1" objNetwork.MapNetworkDrive "z:","\\server\share2" . . . A better way would be to turn the mapping script section into a function/subroutine and call the function from the main script. Something along the lines of this: Code:
MapDrive "x:","\\192.168.25.103\c$"
MapDrive "y:","\\192.168.25.103\e$"
wscript.quit
Function MapDrive(strDriveLetter,strPath)
set objNet = CreateObject("Wscript.Network")
set objFSO = CreateObject("Scripting.FileSystemObject")
if not ( objFSO.DriveExists(strDriveLetter) ) then
objNet.MapNetworkDrive strDriveLetter,strPath
else
set objDrive = objFSO.GetDrive(strDriveLetter)
if not (objDrive.ShareName = strPath) then
objNet.RemoveNetworkDrive strDriveLetter,true,true
objNet.MapNetworkDrive strDriveLetter,strPath
end if
end if
End Function
yeah.. I think he called me lazy or something along those lines asking why I didn't just post the script. I havea copy of the IM conversation somewhere on my work laptop (working on my home machine now). |
|
|
|
|
|
Top | #9 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Thanks again, for your input and time.
I am going to be making the mods to the SBS2003 Domain Controller in the morning, and I am certainly going to use that last one you posted. Everyone is going to see the same two drives: So it should look like this: Code:
MapDrive "M:","\\server\D:\Data$"
MapDrive "N:","\\server\D:\Spec$"
wscript.quit
Function MapDrive(strDriveLetter,strPath)
set objNet = CreateObject("Wscript.Network")
set objFSO = CreateObject("Scripting.FileSystemObject")
if not ( objFSO.DriveExists(strDriveLetter) ) then
objNet.MapNetworkDrive strDriveLetter,strPath
else
set objDrive = objFSO.GetDrive(strDriveLetter)
if not (objDrive.ShareName = strPath) then
objNet.RemoveNetworkDrive strDriveLetter,true,true
objNet.MapNetworkDrive strDriveLetter,strPath
end if
end if
End Function
I won't bother with going around and disconnecting the M: mapped drives already there. How does this look to you? I can't thank you enough for your time.... Heeter |
|
|
|
|
|
Top | #10 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
no worries
|
|
|
|
|
|
Top | #11 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Update,
Thanks Fitz, I still haven't quite figured out the filepath for the shared drives on the network, but it is something that I will continue to play with as I go along. Right now, it is disconnecting the manually mapped drive when the user logs on, but not issuing the vbs mapped drives. I erased the default .bat file that was in the logon script section of the profile. But I was wondering if I could of just added the vbs script to the original line, sort of like this into the logon script line of the profile: Code:
logonscript.bat; mappeddrive.vbs Heeter |
|
|
|
|
|
Top | #12 |
|
█▄█ ▀█▄ █
Joined: April 2005
Location: Massachusetts
Posts: 16,949
Reputation: 4941
Power: 302 |
This is pretty darn cool - when I first read this thread I remember thinking " why do you need error checking for a login script?" But, this actually will override anything they have done locally? Such as....
login script says net use m: \\contoso1\mattspr0n Physical Drive mapping (done manually says) m drive is mapped to \\contoso1\mattschildhoodphotos So regardless, Matt's pr0n will always be mapped to M? How would you go about addressing login scripts that don't seem to run when the person is working from home? Obviously they don't hit the PDC when logging into their machines using cached credentials, and after connecting to the VPN can only access drives that were mapped from a previous session. |
|
|
|
|
|
Top | #13 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
Originally Posted by kcnychief
yup.. the M: drive would also map correctly.
as for VPN, it may depend on what VPN Client is being used.. most clients have some option to run a script after login (in which case, see if it will handle vbs scripts or just wrap the vbs script in a batch file). The bigger question on VPN logins is how to get any login script to run at all if they already logged in via Cached credentials.. connecting via VPN using the "login using dial-up" checkbox on the main GINA is a different story.. If your VPN client supports it, it may be possible to run a post-login/post connection script off the VPN client which might require the script be local on the machine.. and if it won't support vbs would require a BAT file wrapper.. the harder part on that is making sure the local script is updated when changes to the main script changes. edit: you could also write a local process/service that installs on the client to either watch for VPN connections and/or monitors IP changes and runs the login script that way. It's the same issues as when a laptop user can start a computer off the network and later plug in and/or dock the laptop - no login scripts. Or if a computer's network cable is unplugged at startup and after logging in with cached credentials, they plug in the network cable.. |
|
|
|
|
|
Top | #14 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Update:
I am still having issues with my mapped drive vbscript. It is disconnecting the existing M drive, but it is giving me errors, please see screenie. Folder to map is on E:: drive (E:/ClientData), would like to call it M: drive Thanks, Heeter |
|
|
|
|
|
Top | #15 |
|
█▄█ ▀█▄ █
Joined: April 2005
Location: Massachusetts
Posts: 16,949
Reputation: 4941
Power: 302 |
I'm assuming if it can't find the path from the computer that is trying to run it, the user who is running the script might not have access to that admministrative share?
|
|
|
|
|
|
Top | #16 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
All the users that I have applied this script to in their profile have this error come up.
The folder in question has full admin/everyone privileges assigned to it. I do manually map the drive from the workstation when I am logged in as the user. but when I relogon, the mapped M: drive gets disconnected (As the script intends it to do) and I get this error. Heeter |
|
|
|
|
|
Top | #17 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
not sure what the problem is. The error indicates that it doesn't think the share exists..
You said the m: drive gets disconnected, it should only get disconnected if the m: drive is connected to a different share (for example: the m: drive is already mapped correctly to \\1600SC\NonClientData, the script would disconnect it). If you have the M: drive connected correctly and the script is disconnecting the drive, then you are passing the wrong share string into the script. just for kicks, go to your start/run and just type in "\\1600SC\clientData$" (without the quotes). |
|
|
|
|
|
Top | #18 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Start/run, It works without the share sign
\\1600sc\clientdata$ <-doesn't work \\1600sc\clientdata <-works Thanks Fitz, for your help so far......... Heeter |
|
|
|
|
|
Top | #19 |
|
XPista7eopard*ix
Joined: April 2004
Location: Chicagoland
Posts: 4,014
Reputation: 2947
Power: 164 |
the $ is the mark to set a share as a hidden share.. if you didn't create it as a hidden share, you don't use the $ symbol.
The share path that gets passed should be the same as what you would use in the start/run (or when you map the drive any other way), so your first line of the script you are using should read: Code:
MapDrive "M:","\\1600SC\ClientData" |
|
|
|
|
|
Top | #20 |
|
Overclocked Like A Mother
Joined: July 2002
Location: In front of my computer
Posts: 2,729
Reputation: 684
Power: 150 |
Oh, Okay
Hidden Share, got it. Thanks for enlightening me on this one, Will fix up the script. If there is two scripts that I would like to use on a user's profile, do I seperate the scripts with a ";" or just a space between them? Thanks a million for your help, I really appreciate it. Heeter |
|
|
|
![]() |
| Bookmarks |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Office and Mapped Network Drives | omg its nlm | Windows Desktop Systems | 5 | January 29th, 2007 10:18pm |
| win 98 behind a router loosing mapped drives on XP | mfenech | Windows Desktop Systems | 0 | October 24th, 2006 8:26pm |
| Automatically re-connect mapped drives? | saeltmarae2k | Windows Desktop Systems | 5 | August 29th, 2006 1:11am |
| what causes mapped drives to be disconnected | usghvn2002 | Windows Server Systems | 12 | March 24th, 2006 10:12pm |
| Keep entering password for mapped drives | Heeter | Windows Server Systems | 15 | January 24th, 2006 11:25pm |