Sypher
(Fresh Scripter)
2006-06-07 01:41 PM
Printer Location Tracking

Hello,

I am running a couple of Win2k3 (Enterprise) servers. One of this server is hosting all the printers (100 to be exact). These 100 printers all have names like AMS-PR1 to AMS-PR188 (only the uneven numbers are on this server).

All the printers have a department in their Location (Sales, Development etc..), and the Locationname in the Descripting (Amsterdam)

I'm using KiX as a logon script, but now theres a thing i can't seem to fix.

What i want to do is adding a printer to a user, but only a printer in his own group (e.g. Sales).. One of the random printers in the department..

Is there a way to do this with KiX?

I hope to hear from you soon, Thanks in advance!


NTDOCAdministrator
(KiX Master)
2006-06-08 02:58 AM
Re: Printer Location Tracking

Hello and Welcome to the board.

Yes it can be done, but why would you want to install a "random" printer even from a specified group?

What version of KiXtart are you using and what are you desktop OS that are in use that need to be supported.


Sypher
(Fresh Scripter)
2006-06-08 10:34 AM
Re: Printer Location Tracking

Hello, First of all, thanks for the reply.
I am running the latest version of KiX (as always). My workstations are all running under Windows XP SP2.

Here's a picture of my network:
- 2 Fileservers with printers spread (uneven = FS1, even = FS2)
- 100 printers per fileserver
- 10 departments (Administration, Aftersales, Transport, Management, Communication, Development, Sales, Marketing, Helpdesk, Sysop)

- All the printers have a location (the departmentname)

Now i have to connect the closest printer, thus one in the office of the department, e.g. Sales..

I hope this clears up any questions

--
Edit:

I guess theres also another "quick 'n dirty" solution, to check what group the user is in, and then add a random printer out the scope (For example: AMS-PR155 - AMS-PR165) but i'd like to use the Location-field)


Sypher
(Fresh Scripter)
2006-06-12 08:51 AM
Re: Printer Location Tracking

Any suggestions?

AllenAdministrator
(KiX Supporter)
2006-06-12 09:32 AM
Re: Printer Location Tracking

See if this thread helps...
http://www.kixtart.org/ubbthreads/showflat.php?Cat=&Board=UBB13&Number=112039


NTDOCAdministrator
(KiX Master)
2006-06-12 09:35 AM
Re: Printer Location Tracking

Well if you want to read the description field then you can check out one of the WMI Printer Scripts and see if it gives you the details you want. If not then you can create your own if it's supported.

If InGroup('Sales') And WMIcode or registry code to read description, Map Printer.

You could also maybe fill out an INI file to read the wanted information and do an Ingroup call.

A few ways to do it. Do you need actual code examples or are you reasonably familiar with KiX to do it?


Sypher
(Fresh Scripter)
2006-06-12 11:05 AM
Re: Printer Location Tracking

I used kix before, but im not that experienced.. Some examples (especially the WMI stuff) are very welcome

Edit:
I found some code like:
Code:

Option Explicit
Dim objWMIService, objItem, colItems, strComputer, intPrinters

strComputer ="."
intPrinters = 1

Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery _
("SELECT * FROM Win32_Printer")

Call Wait() ' Goto Sub Routine at the end

' On Error Resume Next
For Each objItem In colItems
WScript.Echo "Location: " & objItem.Location & " Shared as: \\" & objItem.ShareName
intPrinters = intPrinters + 1
Next

sub Wait()
If strComputer = "." then
strComputer = "Local Host"
else strComputer = strComputer
end if

End Sub

WScript.Quit



But how can this be ported to KiX?


Sypher
(Fresh Scripter)
2006-06-15 12:56 PM
Re: Printer Location Tracking

Sorry to bump this topic, i really need this

AllenAdministrator
(KiX Supporter)
2006-06-15 02:03 PM
Re: Printer Location Tracking

What OS are the clients running?

Mart
(KiX Supporter)
2006-06-15 02:13 PM
Re: Printer Location Tracking

Quote:


....
My workstations are all running under Windows XP SP2.
....





NTDOCAdministrator
(KiX Master)
2006-06-15 02:16 PM
Re: Printer Location Tracking

Al,

My guess is that he wants to do a double check.

1. Check if user is a member of a certain group
2. Check the "description field of the shared printer for a specific phrase"


If InGroup("x") And (Description contains x) EndIf

At least that's how I read it.

The issue would be how to get that shared phrase either from the registry or from WMI


Sypher
(Fresh Scripter)
2006-06-15 02:21 PM
Re: Printer Location Tracking

Well checking groups isn't the problem, checking the printer properties is.. I've searched the forum but i couldn't find any printer querying.

I do have a VBscript (as you can see a few posts up) that gives the location of the printer and the sharename...


Sypher
(Fresh Scripter)
2006-06-23 04:21 PM
Re: Printer Location Tracking

^^ kick ^^

Please?


Kdyer
(KiX Supporter)
2006-06-23 04:52 PM
Re: Printer Location Tracking

Sypher,

Does this help?
Code:

Dim $objWMIService, $objItem, $colItems, $strComputer, $intPrinters
$strComputer="."
$intPrinters=1

$objWMIService=GetObject("winmgmts:\\"+$strComputer+"\root\CIMV2")
$colItems=$objWMIService.ExecQuery("SELECT * FROM Win32_Printer")

?"Looking at Printers installed on: "+@wksta
For Each $objItem In $colItems
IF LEN($objItem.Location)>3
?"Location: "+$objItem.Location+" Shared as: \\"+$objItem.ShareName
$intPrinters=$intPrinters+1
ENDIF
Next
?'Process is complete'
get $



Kent


Richard H.Administrator
(KiX Supporter)
2006-06-23 04:58 PM
Re: Printer Location Tracking

Well, a fairly direct translation losing the wooly bits is:
Code:
Dim $objWMIService, $objItem, $colItems, $strComputer

$strComputer ="."

$objWMIService = GetObject("winmgmts:\\" + $strComputer + "\root\CIMV2")
$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Printer")

For Each $objItem In $colItems
"Location: '" + $objItem.Location + "' shared as: \\" + $objItem.ShareName+@CRLF
Next

Exit 0



Sypher
(Fresh Scripter)
2006-06-26 10:31 PM
Re: Printer Location Tracking

Well as far as i can understand it, it looks like it'll work. Now the point is to randomly select one of the printers that match the user group (which is named G_Groupname) and bind it to the user...

Les
(KiX Master)
2006-06-27 12:12 AM
Re: Printer Location Tracking

I don't get this random bit. What are users supposed to do, check all the printers to see which one they won in the lottery?

Gargoyle
(MM club member)
2006-06-27 12:40 AM
Re: Printer Location Tracking

My geuss was that he is trying to do a "printer pool" type thing. Having a bunch of printers in one location and making sure that everyone does not connect to the same one.

Les
(KiX Master)
2006-06-27 02:23 AM
Re: Printer Location Tracking

Would it not be better to setup printer pooling on the printserver? I mean, the server knows which printer is available at the moment the job is submitted. A logon script that picks a random printer at logon makes no sense. Smells like a supervisor brainfart.

Gargoyle
(MM club member)
2006-06-27 02:58 AM
Re: Printer Location Tracking

I agree, but we don't know the circumstances and you are most likely correct with the
Quote:

Smells like a supervisor brainfart.




Sypher
(Fresh Scripter)
2006-06-27 09:59 AM
Re: Printer Location Tracking

No way, i am not a supervisor of any kind. I am a student and we had received the assignment to setup a network, with as a requirement it needed the Printer Location Stuff.

Also, i have used kix with Kixforms before, so i know it a bit. The only thing is that i asked you guys to give me a "Kickstart" in order to create the script... Geez..


Gargoyle
(MM club member)
2006-06-27 02:28 PM
Re: Printer Location Tracking

The implication was not that you were a supervisor but that you had been directed by one to do something that does not make sense.

Les
(KiX Master)
2006-06-27 03:35 PM
Re: Printer Location Tracking

Correction:
Smells like a teacher brainfart.