Link to home
Start Free TrialLog in
Avatar of geckodeep
geckodeepFlag for Italy

asked on

Renaming the Mapped Drive letter and renaming the Printer.......

Hi there,
      
      I need some advice on the way I should proceed with this matter.
One of the tasks assigned to me in reorganizing our working environment is to change the mapped drive letter for personal and shared drives and rename the attached printers.
I wish to change our personal drive letter from M: to P: by doing so I need to make sure that I don’t screw up with the shortcuts the users might have created on their desktop.
I have renamed the printers on the server and I would like when the user log in, to recognize the new name of the printer that I’ve just changed on the server instead manually disconnecting and reconnecting to the new renamed printer.

I hope its clear what I wish to do. We are working on Windows 2000 server with W2k pro clients.

Just one point: the shared drive J: is mounted through a login script and the Personal drive M: is set in the profile.

Thanks in advance.
GD
Avatar of Ranidae
Ranidae
Flag of Canada image

RE: drive letters

Well, as far as I know, changing the homedirectory drive letter will screw up all desktop shortcuts unless the are created using the %homedrive% variable. The only way otherwise will be to recreate each shortcut.  If everyone had the same shortcuts, you could script this process but somehow I doubt you'd be that lucky.  I'd say get your users to change the path of their shortcuts from "M:\filename" to "%homedrive%:\filename" but I wouldn't want to inflict that much on any user if you know what I mean. :)

Re: Printers

All printer mappings in my environment are done via the users logon script.  When the script runs, it disconnects all printers and then recreates the new printer connections according to the computer the user logs onto.  Thus, the only place I need to change the name is in the script and the teachers get the new name.  If this solution works for you, I can show you the vbscript I use for it.

I would like to see that script as we are looking to do something similar on the printer front

Why reinvent the wheel.

Here is the script to remove printer connections and recreate them by computer name.  Replace the XXXX with apropriate names.

Const Server = "XXXX"
Const objPrinter1 = "XXXX"
Const objPrinter2 = "XXXX"
Const objPrinter3 = "XXXX"
Const objPrinter4 = "XXXX"
Const objPrinter5 = "Room210" 'this printer will ONLY be mapped to all members of the Staff group


Dim LoggedOn
Dim UserObj
Dim objDescription
Dim WSHNetwork
Dim objComputerName

Set objDomain = getObject("LDAP://rootDse")
objDC = objDomain.Get("defaultNamingContext")
DomainName = mid(objDC,4,6)
Set LoggedOn = CreateObject("WScript.Network")
Set UserObj = GetObject("WinNT://" & DomainName & "/" & LoggedOn.UserName)
Set WSHNetwork = WScript.CreateObject("WScript.Network")
objUserName=LoggedOn.UserName
objFullComputerName=WSHNetwork.ComputerName
objComputerName = mid(WshNetwork.ComputerName,1,4)
objDescription = userobj.description

For Each GroupObj In UserObJ.Groups
TMPGroup = GroupOBJ.Name
If TMPGroup = "Staff" Then
GroupStaff = "Staff"
End If
Next

'****************************REMOVING ALL PREVIOUSLY CONNECTED PRINTERS **************************
Set oPrinters = WshNetwork.enumprinterconnections
      For i = 0 To oPrinters.count - 1 Step 2
'      wscript.echo "Port " & oPrinters.Item(i) & " = " & oPrinters.Item(i+1)
      PrinterPath = oPrinters.Item(i+1)
      WshNetwork.RemovePrinterConnection PrinterPath, True, True
Next

'****************************Mapping printer**************************

If objComputerName = "CLS1" Then
      PrinterPath = "\\" & server & "\" & objPrinter1
      WshNetwork.AddWindowsPrinterConnection PrinterPath
      wshNetwork.SetDefaultPrinter printerpath
End If

If GroupStaff = "Staff" Then
      PrinterPath = "\\" & server & "\" & objPrinter5
      WshNetwork.AddWindowsPrinterConnection PrinterPath
End If

'********************End script*************************************

So basically, notice the objComputerName line, it mids out so only the first 4 letters of the computer name are applied to the comparison... I did this to diferentiate computer names such as CLS104 from CLS204, first floor second floor printers... you can set the mid to something diferent or not mid at all.

Add sections for every variable of the computer name you want to map.

I've left other variables in there that call up the username so you could map drives and printers by user, or group as well.

Hope this helps
Avatar of geckodeep

ASKER

Well first of all thanks for your tip Ranidae.
Your solution regarding the printer seems good but i don't think i can use it for our purpose. What i wish to do is to make it in 2 step.
First find a way by means of a script to collect if possible information's regarding all the links available on the Desktop of a user as well as all the printers connected to the server and store all this information with the username in a DB (in our case we have a SQL2k server) or in a excel file.
Second would be to use this information collected and stored in a DB and update it with the new information's and run a new script where it overwrites the existing information by doing this we are sure that we have not missed anything. of course the second step can only be done on a later day after having updated the required information.

Or i think i could use your script if i am able to find a way which computer or which user is connected to which Printer if this is possible then i guess i can create a separate script for printer management which could help us in future.

But for the shortcuts on the desktop i guess the wise approach would be what i mentioned above and none of user has shortcuts with "%homedrive% standards, all of them was done by the shortcut created by the RightClick technique.
ASKER CERTIFIED SOLUTION
Avatar of Ranidae
Ranidae
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial