|
|
|||||||
Hi, I am new to Kix and as I am connecting printers I figured that if I got a mobiles user taking his laptop to different branches will end up with heaps of printer connections. So i was wondering if there is a way to delete all existing printer before connecting the one they need for the site? I already searched arround and coulnd't fint anything - sorry if this was already covered. Thanks for your help. Kat |
||||||||
|
|
|||||||
try: delprinterconnection("") |
||||||||
|
|
|||||||
and this is in the manual. on your search trip, I suggest you always include the manual to it, k? |
||||||||
|
|
|||||||
Tried it and it is not working get an error code 30 |
||||||||
|
|
|||||||
besides I checked the manual ... |
||||||||
|
|
|||||||
30 says: The system cannot read from the specified device. |
||||||||
|
|
|||||||
yep, saw that. Is there a way to use a wild card? I tried deletePrinterConnection ("*") deletePrinterConnection (*) deletePrinterConnection ("\\*") but nothing worked. any ideas? |
||||||||
|
|
|||||||
Ok it seems like I really have to read more carefully the manual as it it must be 'DelPrinterConnection' and not 'DeletePrinterConnection'. Still now I am getting 1801 error which means that the printer cannot be found. @ Lonkero: Sorry, if I sounded a bit harsh I am just trying now for 3 days to get this going. Kat |
||||||||
|
|
|||||||
kat, sure. what more you try without success, that more tense you become and more mistakes you make, like with the name here |
||||||||
|
|
|||||||
Thx, this all gets worse as I am not very good in scripting anyway. When I started I thought map some printers no problem and then I had to work out all kinds of stuff like how to determine in which subnet the user is ... Got that all running fine just cannot find I way to delete all printers first At least I am getting now 'cannot find printer' which is better than the one error before. |
||||||||
|
|
|||||||
Which version of KiXtart are you using? |
||||||||
|
|
|||||||
good question, I just checked to make sure it's version 4.23.0.0 |
||||||||
|
|
|||||||
next question is, what version of kixtart you are using? |
||||||||
|
|
|||||||
richie was faster. and is there network printers available for it to demap? |
||||||||
|
|
|||||||
yep, there are. |
||||||||
|
|
|||||||
k, add this code at the end of your script: Code:
and, where you did call the delprinterconnection(""), replace it with DelPrinterConnections() let us know did that work, k? |
||||||||
|
|
|||||||
works so far fine just it deletes only 2 of the current 4 network printers. But I think I go ahead tomorrow as it is quite late here (10.30pm) and I have to be back to work at 8.30am. Thx for the help - be back tomorrow and tell you how go. Kat |
||||||||
|
|
|||||||
2 was left? so, I would concentrate on those two. most likely they are the cause why kixtart's delprinterconnection is failing. |
||||||||
|
|
|||||||
Hi Lonkero, got it going! All I needed to change on your function was the counter. It seems like the key numbering are going in .5 steps and not in 1. Therfore every second printer was skiped. I changed your counter $c=$c+0.5 and it works perfectly! Thanks heaps for that! now I can start writing the rest. Kat |
||||||||
|
|
|||||||
LOL Jooel won't admit there is anything wrong with his UDF. It deletes evey second printer because whenever a printer is deleted, it skews the index. |
||||||||
|
|
|||||||
wow. and this was not fixed 2 years ago when the UDF was really used? kat, good to hear it works. still, it's an issue of kix and it makes me worry. |
||||||||
|
|
|||||||
All what counts to me is that it is working now. and that you guys are able to help. I still have so many other thinks to solve that everything which works is good! Kat |
||||||||
|
|
|||||||
got it going! All I needed to change on your function was the counter. It seems like the key numbering are going in .5 steps and not in 1. Therfore every second printer was skiped. I changed your counter $c=$c+0.5 and it works perfectly! Because $c is an integer the "0.5" is cast to a value of "0", so your statment becomes $c = $c + 0 - don't worry too much though, because this is what you want. Jooel has fixed the UDF in the UDF forum, I recommend that you get his updated version. |
||||||||
|
|
|||||||
Good idea, done that and it works, thanks all for your help - I am sure I'll be back! Kat |
||||||||
|
|
|||||||
It has to do with increasing the index in ENUMKEY if the current key is being deleted. That results in the next key moving up one index, thus becoming the current key still under the current index. This is basic ENUM functionality! |
||||||||
|
|
|||||||
that is, but if the udf has worked before, this enum functionality has changed at some point. |
||||||||
|
|
|||||||
This worked really well except that it wont delete printers with names over 13 characters can you suggest how to modify the script for these |
||||||||
|
|
|||||||
I've just tried this code in a MS 2003 terminal server environment and am having exactly the same intermittent result as delprinterconnection(""). The script works reliably when called from a mapped drive in a TS session but doesn't remove printers when run as a login script. Any tips? I'm mystified. Thanks, Greg. |
||||||||
|
|
|||||||
Are you certain the login script is running? Are you running login scripts synchronously? Try adding debug code to ensure that the printers are being enumerated. |
||||||||
|
|
|||||||
and try posting to your own thread... |
||||||||
|
|
|||||||
Hello all, I am in the middle of a migration and can't seem to get the scripting to work to delete all network printers. this is what I have any help would be greatlly appreciated.... IF INGROUP("Domain Users") function DelPrinterConnections() dim $c,$bk,$conn $c=0 $bk="HKEY_CURRENT_USER\Printers\Connections" $conn=enumkey($bk,$c) while @error=0 $c=$c+0.5 $conn=delkey($bk+"\"+$conn) $conn=enumkey($bk,$c) loop endfunction ENDIF Thanks again |
||||||||
|
|
|||||||
Welcome to KORG! This won't work as written. You are enumerating a list of objects (registry keys representing printers). The enumeration pointer ($C) is incremented each time. When you delete a key, they all shift down a position, so this method never points to all values. To illustrate this, put 5 coins on your desk, lined up in a row. Point to the first coin with a pen - this represents the enumeration pointer $C. Since the pen is pointing to a coin, we remove (delete) it and move the pointer to the next position. Point to the second coin, remove the first coin, but then move the 4 remaining coins into the original location. Your pointer has now moved past the first position, where the second value now exists. The solution is to enumerate all of the keys into an array, and then loop throuth the array to delete the values. Code: Function DelPrinters() Dim $aPrinters[0] ; array of connections to delete Dim $P, $A ; pointers Dim $Key ; reg key Dim $Tmp ; tmp var Dim $Rv ; Return Value $A = -1 $P = 0 $Key = 'HKCU\Printers\Connections' $Tmp = EnumKey($Key, $P) If $Tmp ; at least one printer? While Not @ERROR $A = $A + 1 ReDim Preserve $aPrinters[$A] $aPrinters[$A] = $Tmp $P = $P + 1 $Tmp = EnumKey($Key, $P) Loop For Each $P in $aPrinters 'delete ' $Key '\' $P ? ;$Rv = DelKey($Key + '\' + $P) Next EndIf EndFunction Glenn |
||||||||
|
|
|||||||
wow! i appreciate the prompt respose. you guys rule. however the script did not work and the reg keys remain.. here is what i have IF INGROUP("Domain Users") Function DelPrinters() Dim $aPrinters[0] ; array of connections to delete Dim $P, $A ; pointers Dim $Key ; reg key Dim $Tmp ; tmp var Dim $Rv ; Return Value $A = -1 $P = 0 $Key = 'HKCU\Printers\Connections' $Tmp = EnumKey($Key, $P) If $Tmp While Not @ERROR $A = $A + 1 ReDim Preserve $aPrinters[$A] $aPrinters[$A] = $Tmp $P = $P + 1 $Tmp = EnumKey($Key, $P) Loop For Each $P in $aPrinters 'delete ' $Key '\' $P ? $Rv = DelKey($Key + '\' + $P) Next EndIf EndFunction ENDIF |
||||||||
|
|
|||||||
You aren't calling the function! Code: If InGroup('this group') DelPrinters() ; call the function EndIf Function DelPrinters() ; define the function ; code goes here... EndFunction A common mistake. Glenn |
||||||||
|
|
|||||||
wow! you trully are a lifesaver! |
||||||||
|
|
|||||||
Originally Posted By: bertus02 wow! you trully are a lifesaver! Glenn |
||||||||
|
|
|||||||
I see that the script deletes the registry keys, thus deleting the printers from the printer list. How does this compare to the delPrinterConnection ("\\Server\Printer") command instead? Are they both doing the same thing? How would you go about delete Local TCP/IP Port Mapped printers? |