Chad's Eclectic Tips and Tricks

Tips some days, not everyday, mostly Windows & SharePoint from Chad Schultz - Premier Field Engineer

October, 2012

  • Tip 51: Cleanup on Isle 3! Get Back Disk Cleanup Wizard on Windows Server 2008 & 2012

    This tip is for the server administrators out there with messy disks on Windows Server 2008 and 2012.

    I just finished upgrading all of my lab infrastructure to the newest coolest and cloudiest server OS, Windows Server 2012. I did an actual upgrade also, not a custom installation. The difference being that an upgrade will keep your files and folders in place so you do not lose any data; while a custom install will format your system disk.

    The upgrade finished without a hitch on all on my machines; 2 domain controllers, 2 Hyper-V servers and a storage server. The only issue was that on all of my system drives I was running out of room, on account the system drives are SSD or virtual hard drives.

    When you do an upgrade instead of a custom installation the machine will end up with a folder on the root of the system drive, normally C: called Windows.old. This is the old version of Windows and unless you have some files saved in the Windows or Program Files folders you can safely delete this after the upgrade is complete. Note that any files saved in the user profiles location will be copied to the new installation.

    Only problem with deleting the Windows.old folder is that if you try to just delete the folder you will receive nasty errors and warnings like these.

    Now you could go into the permissions and take ownership of all of the files and get through the system file warnings, but it would be much easier if you could just use Disk Cleanup Wizard to delete the old folder. Plus you get the option of deleting other non essential and temporary files with Disk Cleanup. Now to run the cleanup right-click the disk and select properties and there should be a button next to the pie chart of the disk, oops, it's not there!

    If you search for missing disk cleanup on Windows Server, you may end up at this Technet page; http://technet.microsoft.com/en-us/library/ff630161(v=ws.10).aspx. Which directs you to copy files from crazy Windows\WinSxS locations and run the Cleanmgr.exe program. I will have to track down how this got published, but just know that it is not a good practice to just go copying files from the Windows Component Store (WinSxS) willy nilly. Plus if you do this the button will still not be shown on the disk properties. So how do you get the disk cleanup back the right way?

    The Desktop Experience feature is the feature that enables disk cleanup on Windows Server 2008 and 2012, so just install this feature and you can cleanup you disk as much as you want.

    In Windows 2008 use Server Manager to add the feature.

    In Windows Server 2012 it's even easier, use PowerShell to enable the feature.

    Add-WindowsFeature Desktop-Experience

    Now the button is back and you can delete the folder.

    Now go clean you disks before the next tip!

  • Tip 52: Mixing the Old and New; Setting a Printer’s Print Processor Using PowerShell, WMI and Setprinter.exe

    This tip has a little bit of everything thrown into the mix. Old Windows Resource Kit files, PowerShell, WMI and printers all in one; for the same low price of free!

    I just helped one our hardware partners on an issue with printing. Turns out I don’t know as much as I thought about the subject before I met this individual, but they did ask me to help with some topics I am knowledgeable about, what are the chances of that?

    The issue was that the Print Processor for all of the manufacturer’s printers installed on a machine needed to be changed but not any other printers, they needed to stay the same. If you don’t know what a print processor is or you would like very detailed information on how printing works see this; http://technet.microsoft.com/en-us/library/cc783789(v=WS.10).aspx. Basically, in the Windows 200/NT days Localspl.dll was the main DLL for local printing, including the print processor. Since Windows XP/2003 the print processor is a separate DLL called winprint.dll. Each printer manufacturer can create their own print processor and usually does.

    There are a few ways to change the print processor for a printer. One is to go to the printer’s properties in Control Panel->Devices and Printers->Right Click->Printer Properties->Advanced tab->Print Processor….

    On my Windows 8 machine I have 2 print processors, hpfpp70w and winprint. To change the processor for the printer, select the processor on the left and the default data type on the right. Most of the time you will not need to change your print processor, but if you are having printing issues you may want to. In most cases you will want to select a print processor from the same manufacturer of the printer. For my HP printer I would select the hpfpp70w processor, but to troubleshoot I may want to try the more generic winprint processor. Now imagine if you had 100 or 1,000 or 10,000 client machines with 1-10 printers installed on each to change. Using this way I would next expect to see you in a couple years.

    The next way you can change the print processor and other printer properties is with a tool from the Windows 2003 Resource Kit called Setprinter.exe. This is nice as you can change the setting in 1 command like so.

    Setprinter.exe <PRINTER NAME> 2 pPrinterProcessor=winprint

    That certainly cuts down on the number of clicks to change the printer properties, but still would take a while to get the names of printers that needed changing and running the Setprinter.exe commands.

    Since in this case all of the printers of the same manufacturer needed to be changed I needed a better way. Enter PowerShell. In PowerShell you can start a process/command using the Start-Process cmdlet. So why not put them both to use. Below is the script I created to set all printers with the manufacturer’s name in the printer name to the winprint print processor. The script will stop the spooler service using the built in Sc.exe command and then query WMI for all of the printers that contains the manufacturer’s name. It then cycles through them and sets the print processor using Setprinter.exe and finally starts the spooler service using Sc.exe again.

    $args="stop Spooler"

    start-process sc.exe $args

    $colItems = Get-WmiObject Win32_Printer | ? {$_.Name -like "*Manufacturer*"}

    foreach($objItem in $colItems) {

    $args = """" + $objItem.Name + """" + " 2 " + "pPrintProcessor=winprint"

    start-process setprinter.exe $args -wait}

    $args="start Spooler"

    start-process sc.exe $args

    Of course you can change other printer properties. To view some of the information you can change you can run the following command that will output all of the level 2 properties for all of the printers on a machine. The double quotes means all printers.

    SetPrinter.exe -show "" 2

    Here is some sample output of my printers.

    Sometimes you have to mix some of the old with the new to get the job done.

    Those of you on Windows 8 or Windows Server 2012 can also use the new PowerShell printer cmdlets to manage printers. I could not find a lot of information on the new functions, but below is a list from PowerShell get-Help.