|
|
|||||||
I need to add something to my login script that checks to see if the user currently has a LPT1 or USB printer as their default. If not I need to map the user to a network printer. Now I know I can easly see if they have a LPT1 printer using IF EXIST('LPT1:') any idea what I can do with a USB printer? DOT4_001 is the port showing in windows and doesnt seem to want to work if I use that in place of LPT1: Anyhelp? Thanks Dennis Tadin |
||||||||
|
|
|||||||
Hello and Welcome to the board You could read the registry and do an IfInStr after enuming the keys HKEY_CURRENT_USER\Printers\Connections If you need further assistance assembling the code to do this please let us know. |
||||||||
|
|
|||||||
ntdoc I havent used kixtart to check the registry yet. So yes im probley going to need some help with that part. what am I looking for inside connections? I have users with a dozen or so diffrent types of printers some lpt some usb. I really dont want to check form every diffrent type of printer (I see in connections it lists them by names and not by port) |
||||||||
|
|
|||||||
Not sure... if I get time I'll look and see if one of the many UDFs can help or how to detect that alone. I don't have any USB printer installed at the moment so can't really check, but I may have access to one that has a USB printer installed. |
||||||||
|
|
|||||||
PrinterList() will help you get the ports, but you will still need some code to figure out what printer is the default. |
||||||||
|
|
|||||||
Try this... Code:
|
||||||||
|
|
|||||||
Well there is a UDF to get that too |
||||||||
|
|
|||||||
I figured there was... I just couldn't put my hands on it. |
||||||||
|
|
|||||||
GetDefaultPrinter() - Returns default printer http://www.kixtart.org/ubbthreads/showflat.php?Cat=0&Number=117544 |
||||||||
|
|
|||||||
Just having a little fun with this... Microsoft.com - Managing Printer Operations Code: break on Produces: Code:
|
||||||||
|
|
|||||||
Allen can you confirm this works for you against a remote computer? On every system I've tried so far it comes back blank. It does work locally though. |
||||||||
|
|
|||||||
I did not do a whole lot of testing on it... and I bet your finding are right... I'll change it. Thanks for looking at it. |
||||||||
|
|
|||||||
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_printer.asp Just reading through this article and noticed that the Default Property only works on XP and above. |
||||||||
|
|
|||||||
Yeah I know, but I've run it against other XP and 2003 systems and they come back blank. Not sure if I'm having some type of networking issue or what so was curious if it worked remotely for you. |
||||||||
|
|
|||||||
Ok guys taking your code I thought I had a solution. (This is just a test to see if it works) But it doesnt seem to want to work... Any ideas? Help this n00b kixtart user ;p Code: break on |
||||||||
|
|
|||||||
I ran your script Code: $printerport= "$dp.PortName" I would not use quotes because $dp is a variable Code: ? "Printer PortName: " + $dp.PortName This returns the (IP) port name of my (default) home printer Your script seems OK to me... |
||||||||
|
|
|||||||
Um yeah witto, but the part thats not working is the if $printerport = ("IP_192.168.4.39") ? "IP Port Exists" else ? "IP Port Does not Exist" endif Change that ip to the ip of your home printer and see if it says IP Port exists... It doesnt detect it right. Not sure what I am doing wrong. |
||||||||
|
|
|||||||
Well, I added Code: If $printerport = "IP_192.168.222.1" and removed the other If/EndIf statements. The output on the screen is: Code: Printer PortName: IP_192.168.222.1 |
||||||||
|
|
|||||||
It was those damn quotes, I fixed that and your right its working now. Thanks Witto! Dtadin |