Page 1 of 1 1
Topic Options
#169326 - 2006-10-12 05:25 PM need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
Hello,

We are moving all of our printers from one server to another. We have the new server and printers set up. We have a new script that will check a users group membership in 70 or so groups will map associated printer for each group they are in (usually not more than 3 or so).

We want to remove ALL of the mappings associated with the old server. I thought the unmapprinters function would server us well if we just put all of the printers on the new server in the ini (thus removing all of the old mappings).

I am having a difficult time figuring out the EXACT format of the INI file. Could someone advise me as to what it should look like if I want the INI to contain merely the list of print shares or printers that exist on the new server, without regard to OS, uses, groups, and default printers etc. as mentioned in the script comments?

Lets say the new shares are:

\\newserver\printer1
\\newserver\printer2
\\newserver\printer3

I have seen previous posts (by tjcarst) where a the user used "[PRINTERS]" and numerated each line, but I don't see in the script comments that these are required.

TYIA

P

Thanks

Top
#169327 - 2006-10-12 05:31 PM Re: need help with unmapprinters udf ini format
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
From the description of the UDF
Quote:

;ACTION Removes mapped printers not listed in an .INI file





So you should be able to do what you want by having an empty INI file.

Top
#169328 - 2006-10-12 05:35 PM Re: need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
I am not sure I agree. I want to LEAVE the clients new server printers that are already mapped alone. thus I would think those new printers should be in the INI.
Top
#169329 - 2006-10-12 05:49 PM Re: need help with unmapprinters udf ini format
Gargoyle Offline
MM club member
*****

Registered: 2004-03-09
Posts: 1597
Loc: Valley of the Sun (Arizona, US...
Yes you would be correct.

I think Jens will have to answer as to what can be left out of the INI file and what has to be in there to make it work.

Top
#169330 - 2006-10-12 07:29 PM Re: need help with unmapprinters udf ini format
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Please take a look here and see if this helps you.

http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=37276&an=&page=&vc=1

Top
#169331 - 2006-10-12 08:38 PM Re: need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
WOW .. seems pretty complicated. Wish Jens was around. :-)

I will delve.

Top
#169332 - 2006-10-12 09:34 PM Re: need help with unmapprinters udf ini format
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
No, it's actually VERY simple to do.

You create an INI file with the previous server/printer names and on the otherside of the = sign you put the new server/printer names.

You use the PriMapState() UDF and it goes through and checks the INI against the installed printers and if there is a match it changes the OLD name to the NEW name.

Top
#169333 - 2006-10-12 10:46 PM Re: need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
YES!! Very slick. I am having a hard time with the upper part .. specifically HOW each line is split into two parts (old,new). I would think the delimeter is =, but it seems you are using chr(10).

Also, I am not so sure I need the Select part, as I have only one domain.

Top
#169334 - 2006-10-12 10:51 PM Re: need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
Also .. I only want users to run this ONCE via our login script, as I am sure it will take a while to check all 70 printers. What is the best way to tag a user so that it only does run one time? a reg value? a 0k text file in their profile?
Top
#169335 - 2006-10-13 12:31 AM Re: need help with unmapprinters udf ini format
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
I have to run but I'll help you with it later tonight or tomorrow.

As for speed, no the amount of printers in the list is not an issue.

I had 400 printers in the list and it ran in less than 1 second.

Top
#169336 - 2006-10-13 06:45 AM Re: need help with unmapprinters udf ini format
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
Okay... I've modified the script some and commented it.

I would let the script run for every logon for like a couple of weeks myself.
It only takes less than a second on a 100MB LAN to read the INI file and check the Registry if any of the old ones exist or not.

It will only add a printer connection if the old one is found.

Remember though that Printer NAMES and Printer SHARE NAMES are not the same.

Hopefully whoever setup the printers the first time set the PRINTER NAME and SHARE NAME to the same values so you don't have to mess with it.

Create a PRINTERS.INI file and place it in your NETLOGON share and make sure it replicates to all DC.

It should look something like this with all your printers in the file.

[PRINTER_MAP]
\\OLDSERVER\OLDPRINTERNAME1=\\NEWSERVER\NEWPRINTERNAME1
\\OLDSERVER\OLDPRINTERNAME2=\\NEWSERVER\NEWPRINTERNAME2
\\OLDSERVER\OLDPRINTERNAME3=\\NEWSERVER\NEWPRINTERNAME3


Then either add this to your logon script or create a RESETPRINTERS.KIX script and call it from you Logon script.

Here is what the script should look like.
NOTE!! This script has not been tested - it looks correct but may contain errors since it has not been run in a real test.
It also has no logging or real error checking for feedback which you may or may not want.


;Set our options 
If Not @LogonMode
Break On
Else
Break Off
EndIf
Dim $SO
$SO=SetOption('Explicit','On')
$SO=SetOption('NoVarsInStrings','On')
$SO=SetOption('NoMacrosInStrings','On')
$SO=SetOption('WrapAtEOL','On')

;Dim our vars
Dim $ReMapPrinters

;Call the ResetPrinters UDF to perform the remapping of
;old printer maps to the new printer maps
$ReMapPrinters = ResetPrinters()

Function ResetPrinters()
;Dim our vars
Dim $PrintersINI, $Key, $Nul

;Assign the location of the PRINTERS.INI file to a var
$PrintersINI = @LDrive + 'PRINTERS.INI'

;Check that there are no Windows 9x systems trying to run this script
If @INWIN = 1
For Each $Key In Split(ReadProfileString($PrintersINI,'PRINTER_MAP',""),chr(10))

;If we find an old printer mapping we add connection to the new one
If PriMapState($Key)
$Nul = AddPrinterConnection(ReadProfileString($PrintersINI,'PRINTER_MAP',$Key))
If PriMapState($Key) = 2
$Nul = SetDefaultPrinter(ReadProfileString($PrintersINI,'PRINTER_MAP',$Key))
EndIf

;Remove the old mapped printer
$Nul = DelPrinterConnection($Key)
EndIf
Next
EndIf
EndFunction

Function PriMapState($_Pri)
If Len(ReadValue('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Devices',$_Pri))
If InStr(ReadValue('HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows','Device'),$_Pri)
$PriMapState = 2
Else
$PriMapState = 1
EndIf
EndIf
EndFunction

Top
#169337 - 2006-10-13 06:47 AM Re: need help with unmapprinters udf ini format
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11623
Loc: CA
A little bit older of a post but quite similar script is listed in the Examples as well.

Move Printer Server
http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=118702

Top
#169338 - 2006-10-13 08:07 PM Re: need help with unmapprinters udf ini format
pfarrelli Offline
Fresh Scripter

Registered: 2005-11-16
Posts: 46
Now this is SWWEEET. I will test and let you know if we use it.

Thanks!

Top
#169339 - 2006-10-15 11:10 PM Re: need help with unmapprinters udf ini format
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Why do you guys need me?

BTW, the UnMapPrinters UDF header fully describes the .iNI file format:
Code:

;REMARKS Companion function to MapPrinter at http://www.kixtart.org/cgi-bin/ultimatebb.cgi?ubb=get_topic&f=12&t=000109
; The printer.ini file has the following format:
; [Printer name] = Name of the printer share
; Win2K3 = Name of the printserver(s) for Windows 2003 Server computers
; WinXP = Name of the printserver(s) for Windows XP computers
; Win2K = Name of the printserver(s) for Windows 2K computers
; WinNT = Name of the printserver(s) for Windows NT computers
; GroupInclude = User groups to be included in the printer connection
; CompExplude = Computers to be excluded from the printer connection
; Users = Users to be included in the printer connection
; FullName = Full name of the printer
; Default = Boolean indicating whether this printer will be the default printer
;



However, this UDF is rather old and was part of a login script system. The main purpose was to remove mapped printers from those users that would no longer have access to that printer


Edited by sealeopard (2006-10-15 11:11 PM)
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 557 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.071 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org