Automatically replace a printer connection

John Savill

March 11, 2006

10 Min Read
ITPro Today logo in a gray background | ITPro Today

Windows Tips & Tricks UPDATE--January 30, 2006

Subscribe to Windows IT Pro: https://store.pentontech.com/index.cfm?s=1&promocode=eu205xxL

Make sure your copy of Windows Tips & Tricks UPDATE isn't mistakenly blocked by antispam software! Be sure to add [email protected] to your list of allowed senders and contacts.

===============

This email newsletter comes to you free and is supported by the following advertisers, which offer products and services in which you might be interested. Please take a moment to visit these advertisers' Web sites and show your support for Windows Tips & Tricks UPDATE. DSRAZOR for Windows http://www.visualclick.com/content/dsrazorw.htm?source=ITProT&T1 Argent Software http://www.argent.com/w/whitepapers_mom.html?Source=WNT

==========

==== Sponsor: DSRAZOR for Windows ==== DSRAZOR for Windows, from Visual Click, is your answer to a more secure and manageable network environment. Whether your organization is big or small, DSRAZOR's patented drag-n-drop interface gives you the power to build a more stable and secure network, with a click of the mouse! Time for Network Compliance? Let Visual Click's DSRAZOR for Windows help you become compliant! Receive detailed reports of all security settings and definitions for your Active Directory. DSRAZOR will give you the ability to pinpoint specific security weaknesses. Register for your Free Assessment today! http://www.visualclick.com/content/dsrazorw.htm?source=ITProT&T1

==========

FAQs Q. What are the versions of Windows Vista? Q. What is the Windows Metafile Format (WMF) vulnerability? Q. What is Trinity Rescue Kit 3.0? Q. How can I use a Windows Management Instrumentation (WMI) script to list printers? Q. How can I use a script to automatically replace a printer connection with another? ==== Sponsor: Argent Software ==== NETWORK TESTING LABS COMPARES ARGENT TO MOM 2005 Network Testing Labs, one of the world's leading independent research companies, concluded that "Argent's suite had a smaller footprint, was more scalable, supported more platforms, had a more responsive and intuitive user interface and gave us more useful reports," the report says. "Argent's suite of monitoring products emerged from our testing with flying colors." Download this FREE Comparison Paper now: http://www.argent.com/w/whitepapers_mom.html?Source=WNT

==========

==== FAQs ==== by John Savill, FAQ Editor, [email protected] Q. What are the versions of Windows Vista? A. Vista will ship in seven different versions that center on home or office use: - Vista Starter Edition, which maps to Windows XP Starter Edition, is for consumers in emerging markets with very low-end PCs. This version is a subset of the Vista Home Basic Edition and will ship in a 32-bit version only. Only three concurrent applications can run, and no inbound connections are supported. Fast user switching and account passwords aren't included. - Vista Home Basic Edition is designed for single-computer home environments. It includes features such as firewall, Security Center, antivirus, antispyware (Windows Defender), antispam, and phishing protection. The new Aero UI will be included as well as updated Movie Maker, Media Player, and Windows Mail (Outlook Express replacement). This version also has a photo-library manager and peer-to-peer (P2P) ad hoc meeting capabilities, and more. - Vista Home Premium Edition builds on Home Basic and adds Media Center and Media Center Extender functionality, DVD video authoring and ripping (with Digital Rights Management--DRM--protection) and High Definition (HD) support. It also features increased networking capabilities, including WiFi configuration, Internet File Sharing, and synchronization among PCs. - Vista Professional Edition includes the ability to join domains, Remote Desktop, Encrypting File System (EFS), and Microsoft IIS (similar to XP Pro). It will also include Tablet PC capabilities. - Vista Small Business Edition is designed for small companies that don't have full IT teams. This version is built on Vista Pro and includes additional client-side functions such as Volume Shadow Copy Service (VSS) support, PC fax and scanning, and subscriptions to the Windows and Office Live services. It also includes a network-backup solution. - Vista Enterprise Edition is available only to Software Assurance (SA) customers and not for retail purchase. It builds on Vista Pro and adds additional security features, such as full-volume encryption (BitLocker Drive Encryption), and secure startup. Microsoft Virtual PC and Multilingual User Interface are also included. It's designed for high-end business users. - Vista Ultimate Edition is a combination of Vista Pro and Vista Home Premium with additional game-optimized technologies. It will likely have additional access to online services. There will be no corporate editions of the Vista Home and Ultimate lines, which means they'll require activation. -------------------- Q. What is the Windows Metafile Format (WMF) vulnerability? A. A vulnerability was found in the WMF definition that affects the Windows rendering engine (shimgvw.dll), which, unlike previous vulnerabilities, requires no user interaction to be activated. An infected image only has to be viewed on a Web site or in an email or even accessed via a desktop search engine (such as Google Desktop Search). It then can run code on the PC that could install malware. You can find more information about the vulnerability at the following URLs: - http://www.microsoft.com/technet/security/advisory/912840.mspx - http://www.kb.cert.org/vuls/id/181038 Microsoft released a fix on January 5--out of the regular fix cycle because the problem is so critical--and you should install the fix as soon as possible. -------------------- Q. What is Trinity Rescue Kit 3.0? A. I first discussed this tool in the FAQ "What's the Trinity Rescue Kit?" at http://www.windowsitpro.com/Article/ArticleID/39671/39671.html. A new version is now available at http://trinityhome.org/trk/dl-hyguard-trk30.html , and you can find more information at http://trinityhome.org/trk . This new version is still a Linux-based recovery tool for Windows, but it has several new features including: - Read/write support on NTFS drives. The command "mountallfs" gives you read-only access to NTFS drives. Using the command with the -f option gives you safe, fast write access to NTFS drives, but you can create only 10 files per subdirectory, so it's not an ideal solution if you have to do many copies. Mountallfs -c gives you full write access, but you need to add ntfs.sys and ntoskrnl.exe from Windows XP Service Pack 1a (SP1a) manually, as the Usage Howto section of the Web site explains. - Simple password resets via winpass - Offline virus scans with two different antivirus tools (F-prot and ClamAv) - Registry editing - Partition editing with qtparted - NTFS file undelete functionality - Lots of hardware support, from most network cards and disk controllers to USB storage - Fast boot times (less than 40 seconds) - Network NTFS cloning - Remote administration possible - Network environment preconfigurable at boot - Integrated Web browser (links) All this functionality is from a bootable CD-ROM; no information is written to the physical disk. For example, you can use the Winpass shell script, which uses a GNU Windows registry editor called Chntpw, to reset Windows passwords without having to know Linux. The script searches for any available local Windows installations, asks which installation you want to reset the password for, then starts Chntpw, as the figure at http://www.windowsitpro.com/articles/images/trk3passchange.jpg shows. I recommend that you download and burn the utility to a CD-ROM and practice using it. It's a valuable tool for any power user or administrator. -------------------- Q. How can I use a Windows Management Instrumentation (WMI) script to list printers? A. I created the following script, which you can download at http://www.windowsitpro.com/articles/download/listprint.zip , that makes a WMI call and lists details about the printers known on the system: Option Explicit Dim objWMIService, objPrinter, colItems, strComputer strComputer ="." Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2") Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer") ' On Error Resume Next For Each objPrinter In colItems Wscript.Echo "DeviceID: " & objPrinter.DeviceID Wscript.Echo "Caption: " & objPrinter.Caption Wscript.Echo "ServerName: " & objPrinter.ServerName Wscript.Echo "ShareName: " & objPrinter.ShareName Wscript.Echo "DriverName: " & objPrinter.DriverName Wscript.Echo "Default: " & objPrinter.Default Next WScript.Quit Here's an example of the script's output. DeviceID: Tektronix Phaser 850DP Caption: Tektronix Phaser 850DP ServerName: ShareName: ColorPrinter DriverName: Tektronix Phaser 850DP Default: True ---- DeviceID: Microsoft Office Document Image Writer Caption: Microsoft Office Document Image Writer ServerName: ShareName: Printer2 DriverName: Microsoft Office Document Image Writer Driver Default: False ---- DeviceID: Adobe PDF Caption: Adobe PDF ServerName: ShareName: Printer3 DriverName: Adobe PDF Converter Default: False ---- DeviceID: \savdaldc01.savilltech.comCWIS Caption: \savdaldc01.savilltech.comCWIS ServerName: \savdaldc01.savilltech.com ShareName: CWIS DriverName: Xerox DocuPrint N2125 PS Default: False ---- -------------------- Q. How can I use a script to automatically replace a printer connection with another? A. The following code, which you can download at http://www.windowsitpro.com/articles/download/replaceprint.zip , searches for a connected network printer and replaces it with an alternate: Option Explicit Dim objWMIService, objPrinter, colItems, strComputer, objWshShell, strDefaultState strComputer ="." Set objWshShell = WScript.CreateObject("WScript.Shell") Set objWMIService = GetObject("winmgmts:\" & strComputer & "rootCIMV2") ' For Remote: ' Set Locator = CreateObject("WbemScripting.SWbemLocator") ' Set objWMIService = Locator.ConnectServer(strComputer, "rootcimv2", strUserName, strPassword) Set colItems = objWMIService.ExecQuery ("SELECT * FROM Win32_Printer") ' On Error Resume Next For Each objPrinter In colItems If UCase(objPrinter.DeviceID) = UCase("\savdalprinterOldprinter1") Then Wscript.Echo "Found match " & objPrinter.DeviceID & ", replacing" ' Add new printer. Need the ,1,true to wait for shell to complete before continue objWshShell.Run "rundll32 printui.dll,PrintUIEntry /in /Gw /q /n \savdaldc01printerNew",1, true ' Remove the old objWshShell.Run "rundll32 printui.dll,PrintUIEntry /dn /q /n \savdalprinterOldprinter1",1, true If objPrinter.Default Then ' if it's the default set as default objWshShell.Run "rundll32 printui.dll,PrintUIEntry /y /n \savdaldc01printerNew",1, true End If End If Next WScript.Quit You can change the printer the code searches for and what it maps to when it finds a match. ==== Hot spot ==== Avoid Email Armageddon Get the right tools, tips and training that you need to avoid a messaging meltdown when an outage strikes. http://www.windowsitpro.com/go/seminars/messaging/?partnerref=T&Thot130 ==== Events and Resources ==== ( A complete Web and live events directory brought to you by Windows IT Pro: http://www.windowsitpro.com/events ) SQL Server 2005 Up & Running Roadshows Coming to Europe! SQL Server experts will present real-world information about administration, development, and business intelligence to help you put SQL Server 2005 into practice and learn how to use its new capabilities. Includes one-year PASS membership and subscription to SQL Server Magazine. Register now for London, UK, and Stockholm, Sweden. http://www.windowsitpro.com/roadshows/sqlservereurope/index.cfm?code=0201emailannc Learn what impact fragmentation has on users and system activities and discover how quickly fragmentation accumulates as a result of these activities. Plus get the recommendations you need to manage the frequency of defragmentation across your infrastructure. http://www.windowsitpro.com/whitepapers/diskeeper/defragmentation/index.cfm?code=0201emailannc Align compliance with business efficiency, and learn how fax-document management plays a role in your strategy. http://www.windowsitpro.com/go/whitepapers/esker/docmanagement?code=0201emailannc Recover and restore everything in your AD -from users and GPOs to domains and entire forests, including their predefined attributes. http://www.windowsitpro.com/go/whitepapers/netpro/addisaster?code=0201emailannc ==== Featured White Papers ==== Use server and storage consolidation to optimize your existing Windows server infrastructure. Find out how! http://www.windowsitpro.com/go/whitepapers/polyserve/serverconsolidation/?code=0201emailannc ==== Announcements ==== (from Windows IT Pro and its partners) VIP Subscribers' have it all! Become a VIP subscriber and get continuous, inside access to ALL of the online resources published in Windows IT Pro magazine, SQL Server Magazine, Exchange and Outlook Administrator newsletter, Windows Scripting Solutions newsletter, and Windows IT Security newsletter – that's over 26,000 articles at your fingertips. You will also get a valuable one-year print subscription to Windows IT Pro and two VIP CDs (includes the entire article database on CD, delivered twice per year). Don't miss out…sign up now: https://store.pentontech.com/index.cfm?s=1&promocode=eu2762uv Get Two FREE Sample issues of SQL Server Magazine SQL Server Magazine is a must-have in 2006! Order your two free issues today and discover the #1 SQL Server resource for building world-class applications. Along with loads of how-to articles, time-saving advice, and expert tips & solutions, you'll get subscriber-only access to exclusive SQL SERVER content not available any place else.! Order now: https://store.pentontech.com/index.cfm?s=1&promocode=eu2162us

==========

==== Contact Us ==== About the newsletter -- [email protected] About technical questions -- http://www.windowsitpro.com/forums About product news -- [email protected] About your subscription -- [email protected] About sponsoring UPDATE-- [email protected]

===============

This email newsletter is brought to you by Windows IT Pro, the leading publication for IT professionals deploying Windows and related technologies. Subscribe today. https://store.pentontech.com/index.cfm?s=1&promocode=eu205xxb

Manage Your Account You are subscribed as %%$email%%

You are receiving this email message because you subscribed to this newsletter on our Web site. To unsubscribe, click the unsubscribe link:

http://list.windowsitpro.com/u?id=%%SUBSCRIBER_ID_TAG%%

View the Windows IT Pro Privacy policy at http://www.windowsitpro.com/AboutUs/Index.cfm?action=privacy

Windows IT Pro, a division of Penton Media, Inc. 221 East 29th Street, Loveland, CO 80538, Attention: Customer Service Department

Copyright 2006, Penton Media, Inc. All Rights Reserved.

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like