Solved

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

Posted on 2004-08-11
8
245 Views
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.
GD
0
Comment
Question by:geckodeep
  • 3
8 Comments
 
LVL 2

Expert Comment

by:Ranidae
Comment Utility
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.

0
 
LVL 6

Expert Comment

by:Scott_Willcocks
Comment Utility
I would like to see that script as we are looking to do something similar on the printer front

Why reinvent the wheel.

0
 
LVL 2

Expert Comment

by:Ranidae
Comment Utility
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
0
 

Author Comment

by:geckodeep
Comment Utility
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.
0
 
LVL 2

Accepted Solution

by:
Ranidae earned 40 total points
Comment Utility
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.

0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

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…
Learn to move / copy / export exchange contacts to iPhone without using any software. Also see the issues in configuration of exchange with iPhone to migrate contacts.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now