Thursday, 12 July 2012

Print Spooler cleanup

Anyone else ever get that GRRRR feeling when a pattern starts to build up in your head, a pattern of stopping the Print Spooler, deleting the the contents of the PRINTER directory and starting the Print Spooler again? This can be caused by a number of problems like ridiculously large print jobs, print driver errors, corrupt print jobs... This is a 10 minute setup that may save you many more hours of "fixing" printer issues.

I've always dealt with it in a simple way, of course I manually do the clean up first to get the clients printing again, but then I whack in my script. Now I only ever run the script on a server because the clients are almost always connected to the shared printer object on the server. I'll run this usually once a week, say on a Saturday at midnight - when no one will be using the server.

Doing this during the middle of a work day on a Terminal Server where you have 50+ clients connected is going to cause you headaches. Even doing it manually. Simply because most clients won't be able to print at all if they were still connected when you performed the stop, delete, start on the spooler, rarely have I noticed clients still able to print after doing this procedure and I'm not even sure they hadn't disconnected and reconnect because they couldn't print - You have been warned!!! oh and if you have any printer objects setup to only allow certain people to print overnight if they would otherwise hog the printer, script it for a more suitable time when the print run would have finished.

So the script looks like this:

net stop spooler
del /F /Q C:\WINDOWS\system32\spool\PRINTERS\*.*
net start spooler

Simple isn't it?

Of course you could always use any of the other command line tools to stop and start services, such as sc, which will let you run the command on a remote computer, so you could script it & schedule it on your own PC and not have to login to the the printer server, you'd probably have to use psexec to do the deletion part or any other remote deletion commands.

If  you want to be fancy you can do things like write the events to the event log, which your monitoring software can look out for and alert you if it failed, if you are bothered, you can use the "if errorlevel" to hop, skip and jump your way around a complicated script that write events and retries if it fails and so on. I doubt it would fail, and I've not yet seen it fail but perhaps it could if the service hadn't successfully released it's file lock.

I hope this saves you time too!

Tuesday, 10 July 2012

My open letter to Microsoft

Dear Microsoft,

I've had some problems with you in the past, but I genuinely do prefer to use Windows as my sole OS of choice, though this varies from an old XP laptop all the way up to a Windows 8 Release Preview machine, I still prefer to use it over the competition. I loved geeking out with FreeBSD and building the OS from source every few months when there was a major security patch and recompiling my applications on a monthly basis, not because I tweaked them to run faster on my then superb AMD Athlon 64 3000+ based machine, but because I felt more of a uber-geek. A nerd if you will.

Maybe I've grown old, but I really couldn't do that any more and certainly not now that I have children, I don't have the desire to waste all that time and energy, besides I have found my comfort with Windows which I had denied myself for far too long.

I'm going to list my observations as an IT professional and as a Microsoft fan boy.

  • Multiple displays work very well - though it could do with some more options such as pinning programs to the additional monitors taskbar. 
  • Offer people the option to use SkyDrive to Sync ALL their desktop files, Documents folder, Pictures and so on so these are all available on any device they use from the word GO! Of course this means integrating the Explorer version the SkyDrive App into Windows 8, perhaps even offer this with a Windows 7 SP2 to ease the transition between Windows 8 and Windows 7. Trust me, people will love you for this. I'd say go as far as a one-way sync application for XP, which sync's files to SkyDrive and only shows an icon for files already in SkyDrive. You could even offer a SkyDrive based easy transfer affair, which "Just works".
  • One thing I still find clumsy is when using Metro apps to check the time you have to move the mouse to the bottom right hot corner then up and it has to very in the very bottom right corner. I'm sure on tablets it'll be more intuitive, but this needs to be addressed for laptop & desktop users.
  • Using multiple monitors when using a Metro app is great, but what if some of these apps were designed to make use of two or more monitors? Admittedly I've not done any research on this on so please feel free to correct me.
  • The upgrade price... this needs to come down from the traditional £60+ to say £20 or at a maximum £30, if they do this they'll surely have a larger Windows 8 user base quicker making them more money via the Store than if they keep the prices inflated which puts people off. 
  • You guys at Microsoft should build a web version of Windows 8, like you have with Windows Phone 7 / 7.5, to show people just what Windows 8 will be like on their computers. Performance may not be the same but they'll get a good feel for it if you do it right.
  • The Marketing should be cranked up NOW. I've noticed you've started advertising more on TV lately, which is great but you need to keep with it. Keep hammering the IE adverts, Keep hammering the XBOX & Kinect Adverts, bring some Windows Phone Adverts out when Windows Phone 8 is released, pull the current Windows Phone 7 devices off the shelves a month before WinPhone8 and have an intriguing  place holder sign there where they were to get people interested.
  • Open more World Wide Stores, now. They are apparently opening a London store next year. Just the one then? Come on guys, you've only got 20 stores open in the US with a further 1 store of "TBA" status. Your main competitor has many, many more stores. Please crank up the store openings.
  • My phone contract is up a 3 weeks and I've been browsing around to see what's available, my wife has too and she's desperate to get shot of her HTC Wildfire - I've pleaded with her to wait, but she won't wait any longer than 7th August. She would like to see a Samsung Galaxy S3 with Windows Phone 8 running on it. We noticed in every single phone shop they were surprised we were looking at the Windows Phones, some even tried persuading me to look at the other phones and I recall one chap saying "oh you don't want one of those" or words to that effect, of course as a current Android user I had a look but I wasn't amazed by the two titans, Samsung GS3 and HTC One X - the iPhone, pfft, is a pretty much no go for me on many levels, besides who wants a 3.5" screen now days? I'm going to hang on for a Windows Phone 8 and hope I won't be disappointed, which I tried to for a Windows Phone 7 but I couldn't wait any longer with no confirmation dates so ended up with what was a mediocre device at the time, which is now so far behind in hardware capabilities it's silly. Speak to the mobile telco's and get them to start promoting Windows Phone, not just in the US, but across the globe.
  • Make Bing truly Global. It clearly works best if you're a US user.
These are of course just my 2 cents worth and what I feel would help in the long run, not just for the sub-average user, but for yourselves too. As my brilliant ex-manager Gary used to say, "It's all about perception" and I would like to add to that with these words, and Perception is king.

Jayton Garnett

Thursday, 5 July 2012

Running cmd.exe as NT Authority\System on Windows 8

To my surprise Microsoft blocked all normal routes to start an executable in interactive mode as the SYSTEM account. Admittedly you don't need it, but it's interesting that they have disabled running a process in interactive mode with the following usual methods:

at                  (The old way of scripting / creating scheduled tasks from the CLI, it's now depreciated)
schtasks       (The new way of scripting / creating scheduled tasks from the CLI)
sc                 (The CLI Service creation/editing/deletion tool)

You obviously can't use runas as it wants a password and there is no tangible SYSTEM account password to use!

However, I've found that using PsExec from Sysinternals works! This is the almighty command:
psexec -i -s cmd.exe

Replace cmd.exe with your favourite executable.

Of course Microsoft have made this change for security reasons.

Infinite Ping, with timed log

I've had to write this little beauty a few times over the years and realised its quite useful and that people like you may find it useful. You could extend it, or replace the ping with a tracert, pathping or anything else you desire. You can even use it in a scheduled task, which will let you kill it when the ping is no longer needed if you want to check connection problems during a certain time of day. The possibilities are endless! ... well maybe that's over exaggerated, slightly.

echo The time is %time:~0,8% >> PingLog.txt
Ping -n 60 >> PingLog.txt
Echo. >> PingLog.txt && Echo. >> PingLog.txt && Echo. >> PingLog.txt
if %time:~0,5% == 17:10 goto :EOF
Goto Loop

The pings will stop at 17:10, change this time if you wish or delete the line if you want a ping until you stop it manually or your scheduled tasks ends.