Go Premium for a chance to win a PS4. Enter to Win


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

Posted on 2004-08-11
Medium Priority
Last Modified: 2010-04-14
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.
Question by:geckodeep
  • 3

Expert Comment

ID: 11776736
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.


Expert Comment

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

Why reinvent the wheel.


Expert Comment

ID: 11795168
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")
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

'****************************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

'****************************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

Author Comment

ID: 11822870
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.

Accepted Solution

Ranidae earned 160 total points
ID: 11826140
You could add logging to the printer mapping script.  Have the script write what printer to what user in your database as it maps the printers.  This shouldn't be too complicated, but definetly something I've never done.  

There is also a way to have a script enumerate all the files in a folder to a txt, excel or database file.  All you would get though, is the name of the file so when enumerating users desktops, you'd get a lot of "Shortcut to Word.lnk" listed in the (database).  It wouldn't actually tell you the path the lnk file points to.  

I don't know that this type of enumeration would suit your purposes though.


Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
In this article, the configuration steps in Zabbix to monitor devices via SNMP will be discussed with some real examples on Cisco Router/Switch, Catalyst Switch, NAS Synology device.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question