?
Solved

Kix - Printer Removal

Posted on 2010-11-29
3
Medium Priority
?
3,794 Views
Last Modified: 2012-05-10
Dear all,

I need to remove any printers that are attached to a certain server when a user logs in.

DelPrinterConnection("\\servername\printer")

Is there a way of putting a wildcard into it so that any printers that are picked up get dropped?

Or basically is there a Kix command that i can use to remove all printers?
As they are being recreated later on in the script.

Thanks,

Lyon
0
Comment
Question by:LyonJay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 6

Expert Comment

by:ipajones
ID: 34229952
I don't think you'll be able to remove all existing printer connections just using Kixtart.  Also I think DelPrinterConnection() is only supported on Windows NT and Windows 2000.

However, you could call a shell command from within your Kix script, so something like:

shell "%comspec% /c con2prt /f"

Open in new window


You may need to put con2prt.exe (depends on client OS) where it can be accessed by the login script - I would just save it in the nelogon shares root folder.

Hope this helps.
--IJ
0
 
LVL 3

Accepted Solution

by:
Isorg earned 2000 total points
ID: 34235781
here is a bit of code that i have used to remove printers from retired print servers..

;this function will delete all maped printers from a named server
Function DelprinterConnections($server)
    $Rootkey = "HKEY_CURRENT_USER\Printers\Connections"
    for each $key in getkeys($Rootkey)
        if instr($key,$server)
            $ = delkey($rootkey+"\"+$key)
        endif
    next
endfunction



;this function will return an array of key names in a given reg path
function getkeys($path)
    dim $c
    dim $a[0]
    $a[$c] = enumkey($path,$c)
    while @error =0
        $c = $c + 1
        redim preserve $a[$c]
        $a[$c] = enumkey($path,$c)
    loop
    if $c
        redim preserve $a[$c-1]
    endif
    $getkeys = $a
endfunction

Open in new window



Put the UDF's into your kix script, and call the udf

delprinterconnections('OldPrintServer')

any printer with OldPrintServer in it's UNC will be deleted
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses
Course of the Month11 days, 13 hours left to enroll

752 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