Scott Hanselman

The Technical Friend's Essential Maintenance Checklist for Non-Technical Friend's Windows Computer

August 24, '11 Comments [77] Posted in Musings | Tools
Sponsored By

World's Dustiest Computer I visited a friend today and noticed their computer. Of course I did, that's what we do. It was, as are all non-technical computer friends' computers, a 3 year old gray Dell mini tower with a 17" flat screen. In fact, these are the ONLY computers that non-technical computer friends own, you know.

I was there to visit, but I'm genetically incapable of NOT doing a system's check on an old PC. "How can these people LIVE like this?"

If you are reading this blog, you have been in this very situation. Perhaps your wife is waiting in the car to go home even after a lovely dinner with your couple friends and you'll be there in "5 minutes" but you're actually hypnotized by the defragmenter, trying to influence the hard disk head's pixel indicator with your mind. Which sector is next...damn! Immovable!

It's a dance, what we do to our friend's computers, isn't it. It's a dance we done a thousand times, but one that is comforting in its steps. Not surprised, nothing unknown, just maintenance. We've said one day we'll write a script, one day we'll create the ultimate batch file to do all this, but until then, click, download, install, update, rinse, repeat.

Hardware

  • RAM RAM RAM - I've got sticks of the stuff. Today my neighbor had a 512meg machine that was just sad to look at. I've said before, a machine with too little RAM is a three legged dog. You know he's gonna get where he's going but it's hard to watch. I had a couple of gigs of PC-5300 in the car for some reason and I just added it and got them up to 2gigs. Minds were blown.
  • WEI: Window Experience Index - I've gotten into the habit of pressing 'WindowsKey+PauseBreak' on any new Windows Machine to take a look at the Windows Experience Index. It's the number that will tell you, reasonably and quickly, how much your friend's old computer sucks. The top score is currently a 7.9. Usually these machines are 3s and 4s. The important part is the the score is the lowest scoring component. The best part is that most of these low scoring components are cheap. $50 for some RAM, $50 for a new  HD, $50 for a decent Video Card. Update the crappiest part. Again, chances are you have better hardware lying around in your junk drawer than does Non-Technical Friend.

Software

  • Update Drivers - Non-Technical Friend always has a piece of hardware that doesn't work correctly, usually a printer, sometimes an All-In-One scanner/printer/fax. Almost always getting the right drivers solves it. Help them out.
  • Windows Update AND Microsoft Update - They usually haven't set Windows Update to automatically install updates at 3am, and they never have clicked "Yes" to get updates for other Microsoft products. (You have to opt-in.) Visit http://www.microsoftupdate.com on machines before Windows 7 and run the Windows Update applet on Windows 7 and setup updates for Microsoft products (Office, etc. as well as Windows.) Make sure they've got the latest Service Packs for Windows and Office.
  • Anti-Virus - When I visited my friend today I was surprised to see that they had Anti-Virus and Anti-Malware software installed. Always a refreshing surprise. However, they had several installed, and they were fighting. They had AVG, Windows Defender, PC Optimizer, SpyBot, and two other playfully named "anti-spyware" applications as well as four browsers toolbars. I uninstalled the whole lot and installed Microsoft Security Essentials. It's simple, lightweight, solid and free. It's also free on up to 10 PCs for Businesses.
  • Uninstall anything evil - If you want to get a quick look at what's on a machine and uninstall LOTS quickly, look no further than NirSoft's My Uninstaller (download). Remove Toolbars (they think they need them and they never do and won't miss them), and anything that looks like it might destabilize their system. I check out toolbars, add-ins, etc.
  • Update Stuff that can't Update Itself - I usually install FoxIt Reader or at least update Adobe Acrobat and Flash. I updated their Firefox 3.6 (!) to Firefox 6 and installed IE9.
  • Backups or at least DropBox - I always ask "Is your stuff backed up" and they always say "I have been meaning too" or "On my thumb drive last month." I should start charging folks to install DropBox. In this case, I thought about Mozy but my friend really just needed some documents backed up so now they've got DropBox with 2GB free. Windows Live Mesh is another decent option if they are Hotmail/Live Messenger users. Regardless, for goodness sake, get their data to the cloud!

Teaching

  • Tell them about Security - Wanna freak them out? Ask your friend for the last four digits of their social security number (or national id) then hit the Start Menu and search for it. You'll almost always find Excel files, Word documents or PDFs with their super-private information. I've often found scans of their actual id cards. This trick also works with their credit cards. Teach your friends to not keep personal information on their machines.
  • Teach them about History - Avoid looking at Non-Technical Friend's browser history or searching Google for anything that starts with "a", "p" or "s." You don't need to know Non-Technical Friend that well. Perhaps come up with an excuse to teach them about Private Browsing or "Incognito" if you're cool like that.
  • Teach them about Passwords -  Explain how passwords work to your friends. Suggest they use pass phrases, add complex characters, stop saving their passwords in the browsers. If they are cool with it, clear their passwords in their browsers and suggest a password manager.

Maintenance

  • Cleaning - Explain to them the importance of cleaning (or burning) their 10 year old keyboard. Computer keyboards are dirtier than toilets. That's a fact I just made up and I'm totally sure it's true. Get that biomatter off your keyboard and mouse. You wouldn't lick your keyboard but you'll type it on for hours then touch your face. You nasty.
  • Blow the Dust out of their System - It's just the right thing to do. Seriously, keep a bunch of Cans of Air Dusters in your car. I do. Get out the vacuum at your friends house, give them proper warning that it's gonna get NASTY up in here and open up their computer. Chances are this is the first time it's ever been open. It's probably got that "there's a weird sound in the back" groan that's indicative of dust in the power supply. I can't tell you how many times I've just jammed a pencil in there just to get a computer to SHUT UP.
  • Defrag - Of course Windows has its own defragmentation program but I love the MUCH better Auslogics Disk Defrag
  • Startup Programs - Get AutoRuns (or RegEdit to HKLM\Software\Windows\CurrentVersion\Run) and clean up all the random stuff that's starting up but they've forgotten why. If they are slightly technical, suggest Soluto for fixing their startup issues.
  • Tidy Up - Non-Technical Friend typically has some toolbar - perhaps an Explorer Folder or something - pinned off to the far left side of their screen and isn't sure how it got there or how to get rid of it. Clean up these things.
  • Crap Cleaner - It used to be called Crap Cleaner but now it's tamely known as CCleaner and it's the only "cleaner" I trust. I also run Disk Cleanup (as Administrator) that comes with Windows.
  • Resolution - Non-Technical Friend always has a 17" LCD with a native resolution of 1280x1024 but runs their system at 1024x768 and never understands why everything looks blurry. Save them.
  • Join.me - Show them how Join.me works and explain that their Technical-Friend-Who-Isn't-You can help them in the future remotely to tidy up and do routine bits and bobs without needing to come over.

Finally, give them a hug and tell them it's OK. What are your favorite maintenance tasks while visiting Non-Technical Friend, Dear Reader?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

SlowCheetah - Web.config Transformation Syntax now generalized for any XML configuration file

August 23, '11 Comments [71] Posted in ASP.NET | Tools
Sponsored By

I did a post last year called If You're Using XCopy, You're Doing It Wrong that also included a video of my talk at Mix10 where I show how to deploy website with Web Deploy. One of the cooler not-very-well-known features is called Web.config Transformation. Once folks see it, then immediately want a general solution.

First, from the previous post:

You can right-click on your web.config and click "Add Config Transforms." When you do this, you'll get a web.debug.config and a web.release.config. You can make a web.whatever.config if you like, as long as the name lines up with a configuration profile. These files are just the changes you want made, not a complete copy of your web.config.

You might think you'd want to use XSLT to transform a web.config, but while they feels intuitively right it's actually very verbose.

Here's two transforms, one using XSLT and the same one using the XML Document Transform syntax/namespace. As with all things there's multiple ways in XSLT to do this, but you get the general idea. XSLT is a generalized tree transformation language, while this deployment one is optimized for a specific subset of common scenarios. But, the cool part is that each XDT transform is a .NET plugin, so you can make your own.

<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="@*|node()">
  <xsl:copy>          
    <xsl:apply-templates select="@*|node()"/>
  </xsl:copy>
</xsl:template>
<xsl:template match="/configuration/appSettings">
  <xsl:copy>
    <xsl:apply-templates select="node()|@*"/>
    <xsl:element name="add">
      <xsl:attribute name="key">NewSetting</xsl:attribute>
      <xsl:attribute name="value">New Setting Value</xsl:attribute>
    </xsl:element>
  </xsl:copy>
</xsl:template>
</xsl:stylesheet>

Or the same thing via the deployment transform:

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add name="NewSetting" value="New Setting Value" xdt:Transform="Insert"/>
</appSettings>
</configuration>

This kind of config file transformation is so useful in fact, that it's one of the #1 feature requests...as a generalized solution. Folks want to transform their app.configs, or any XML file as part of their builds. Additionally, the current system only runs the transforms as a part of the publish process and folks would rather the transform happen "on F5" or on build. So, my team members Sayed Ibrahim Hashimi and Chuck England have done just that as a small VSiX called SlowCheetah XML Transforms.

In this screenshot I've created a simple Console Application, made a basic app.config, then right clicked and selected "Add Transform." This gives an app.debug.config and app.release.config. You could make and name these however you like, for example app.testing.config, etc.

An app.config file, the transform file, and the result in three panes

For example, here's a basic app.config for my Console app:

<?xml version="1.0" encoding="utf-8" ?>
<configuration >
<appSettings>
<add key="appName" value="Something"/>
<add key="url" value="http://hanselman.com/"/>
<add key="email" value="awesome@hanselman.com" />
</appSettings>
</configuration>

And here's the transform to change my one value in my development time config to a debug value (or test, staging, etc). You can do this for connectionStrings, app keys, compiler settings, anything in an XML or config file.

<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<appSettings>
<add key="appName" value="Demo-debug" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
<add key="email" value="debug@contoso.com" xdt:Transform="Replace" xdt:Locator="Match(key)"/>
</appSettings>
</configuration>

Note the Transform="Replace?" That can be replace, or insert, etc. Lots of choices. The ShowCheetah XML Transform Add-In also adds a "Preview Transform" right-click menu which makes writing these way easier.

The clever part is that there's no magic. All the functionality is installed to %LOCALAPPDATA%\Microsoft\MSBuild\SlowCheetah\v1\ and lives in a standard MSBuild .targets file. You don't even need the plugin if you are installing this on a build server, just copy the files or even check them in with your source and refer to them in your project or MSBuild files. It's added in your project file for you via the tooling like any custom targets:

<Import Project="$(LOCALAPPDATA)\Microsoft\MSBuild\SlowCheetah\v1\Microsoft.Transforms.targets" Condition="Exists('$(LOCALAPPDATA)\Microsoft\MSBuild\SlowCheetah\v1\Microsoft.Transforms.targets')" />

Between the build targets and the added menu items, you get:

  • Added tooling to desktop project to create XDT transforms
  • Ability to transform
    • app.config for desktop projects based on build configuration
    • any XML file to the output folder based on build configuration
  • Added tooling to enable previewing XDT transforms
  • For web projects you can easily transform other XML files during package/publish

Let Sayed and the team know what you think, if it's useful, and if you use it at Sayed's blog, or the SlowCheetah project site on the VS Gallery. Enjoy!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Creating a Podcast Player with HTML5 for a IE9 Pinned Site on Windows 7

August 22, '11 Comments [8] Posted in IE9 | Javascript
Sponsored By

I was looking at the HTML5Rocks podcast player sample today, and remembered I never blogged about the poor man's Podcast Player that I created for the This Developer's Life for IE9 in April. Currently there's a Flash Player on each page on TDL and one day someone will create the One HTML5 Podcast Player to Rule Them All, but so far I haven't seen it. Most are just one-offs and samples. As is my little demo here.

The HTML5Rocks player has some clever bits to it, and it's worth you doing a View Source and checking it out. There is an empty <audio/> tag at the top of the page and they ask it "can you play MP3s?" and show a compatibility message depending on what it says. You can also put text inside the <audio/> element that will be shown if the element isn't supported at all.

 $('#compatibilityMsg').html('Your browser <strong>' + 
($('#player').get(0).canPlayType('audio/mpeg') != '' ? 'can' : 'cannot') +
'</strong> play .mp3 files using HTML5 audio');

Playing audio with the <audio> tag really couldn't be simpler. The HTML5Rocks sample has some extras like setting volume and seeking that you don't see much in samples.

I wanted to create a little Podcast player for TDL that would combine things like Site Pinning and Jump Lists with some custom buttons for pinned sites and use HTML5 audio for playing the show.

So, the features:

  • Pinnable (drag the FavIcon to the TaskBar)
  • Right-click Jumplist with Recent Shows
  • Play the show with Task Buttons from the Preview
  • Previous, Next, Play, Pause.
  • Minimal code

Plus, I'm lousy at JavaScript. Here's what it looks like in action (as an animated GIF, because those are coming back in style, didn't you hear?) for those of you who don't want to try it yourselves.

Here's the general idea as code.

On the home page there is a list of all the episodes, created from a for loop going through the database of shows. I just added a non-preload audio element next to the div for each show:

<audio id="audio-2-0-4-taste" preload="none" src="http://traffic.libsyn.com/devlife/204-Taste.mp3"></audio>
<div class="episode">
<a href='post/2-0-3-education' class="showlink">
<img src="Images//203-lead.png"
alt="2.0.3 Education" width="320" height="220"/>
<div class='title'>
<p>2.0.3 Education</p>
<div class='description'>
<p>Scott and Rob talk to two developers about the role education has played in their careers</p>
</div>
</div>
</a>
</div>

Every show has an href with a class "showlink." I collect them all and give them to my jQuery plugin:

<script>

$(function(){
$(".showlink").IE9PodcastPlayer();
});
</script>

Comments appreciated as I'm still not awesome at jQuery and JavaScript. There are some options/settings that can be passed in, but I set some defaults that work for me since I did it for this one site.

Basically, I add some buttons, setup click events to go forward and backward through the list of shows passed in.

(function( $ ){
$.fn.IE9PodcastPlayer = function(options) {

var settings = {
'playerStatusDiv' : '#podcastStatus',
'currentShowIndex' : 0
};

this.each(function() {
// If options exist, lets merge them
// with our default settings
if ( options ) {
$.extend( settings, options );
}
});

function initButtons() {
try {
// Developer sample code
if(window.external.msIsSiteMode()) {
// Add buttons listener
document.addEventListener('msthumbnailclick', onButtonClicked, false);

// Add buttons
btnPrev = window.external.msSiteModeAddThumbBarButton('/images/prev.ico', 'Previous');
btnPlayPause = window.external.msSiteModeAddThumbBarButton('/images/play.ico', 'Play');
btnNext = window.external.msSiteModeAddThumbBarButton('/images/next.ico', 'Next');

// Add styles
stylePlay = window.external.msSiteModeAddButtonStyle(btnPlayPause, '/images/play.ico', "Play");
stylePause = window.external.msSiteModeAddButtonStyle(btnPlayPause, '/images/pause.ico', "Pause");

// Show thumbar
window.external.msSiteModeShowThumbBar();
}
}
catch(e) {
// fail silently
}
}

function onButtonClicked(e) {
var btnText = "",
lastIndex = 0;

if (e.buttonID !== btnPlayPause) {

switch (e.buttonID) {
case btnPrev:
btnText = "Previous";
settings.currentShowIndex--;
if (settings.currentShowIndex < 0) { settings.currentShowIndex = 0 };
break;
case btnNext:
btnText = "Next";
lastIndex = $('audio').length-1;
settings.currentShowIndex++;
if(settings.currentShowIndex >= lastIndex) { settings.currentShowIndex = lastIndex };
break;
}

stopAll();
$(settings.playerStatusDiv).text(btnText).fadeIn('slow',
function(){playPause(settings.currentShowIndex)}
);
} else {

playPause(settings.currentShowIndex);

}
}

function stopAll() {
$('audio').each(function(){
try {
$(this)[0].pause();
}
catch(e) {
// fail silently
};
});
$(settings.playerStatusDiv).hide();
}

function playPause(podcastID) {
var player = $('audio')[podcastID];
if(player.paused)
{
player.play();
$(settings.playerStatusDiv).text("Playing...").fadeIn('slow');
}
else
{
player.pause();
$(settings.playerStatusDiv).text("Paused").fadeIn('slow');
}

updatePlayPauseButton(podcastID);
}

function updatePlayPauseButton(podcastID) {
var player = $('audio')[podcastID];
try {
if(window.external.msIsSiteMode()) {
if (player.paused)
window.external.msSiteModeShowButtonStyle(btnPlayPause, stylePlay);
else
window.external.msSiteModeShowButtonStyle(btnPlayPause, stylePause);
}
}
catch(e) {
// fail silently
}
}

function addSite() {
try {
window.external.msAddSiteMode();
}
catch (e) {
alert("This feature is only available in Internet Explorer 9. Bummer.");
}
}

initButtons();
updatePlayPauseButton(0);

if(location.pathname == "/")
{
window.external.msSiteModeClearJumpList()
window.external.msSiteModeCreateJumplist('Episodes');

//This is the stuff we selected and passed in!
this.filter(":lt(10)").each(function() {
window.external.msSiteModeAddJumpListItem($(this).text().substring(41,60), this.href, '/favicon.ico');
});

window.external.msSiteModeShowJumplist();
}

};
})( jQuery );

The one part that I had to hack and still feel yucky about is at the end here with the filter() and substring(). See how I have the truncating of the show title hard coded? I was getting too much text when I passed in the whole <a/> element and children. I need to figure out a cleaner way to tell my plugin about my titles AND my audio files. Comments always appreciated.

If you REALLY want to see a jQuery plugin that will enable pinning and dynamic jump lists and isn't a piece of crap that I wrote, check out Pinify the jQuery Site Pinning Plugin or on NuGet.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Summer 2011 Stats - Tailoring your Blog to your Readers' Browsers

August 22, '11 Comments [16] Posted in Blogging | Musings
Sponsored By

I was poking around in my Google Analytics and checking out some browsers stats as I wanted to make sure my new site redesign looked good on the browsers that matter to you all, Dear Reader. As I said in the redesign post (insert egotistical self-quote here. Seriously, who DOEs that?):

This new site design looks great in every awesome browser like Opera, IE9, Chrome, FireFox, and even all the way back to IE7. This site looks like a steaming pile of ass in IE6. As it should. 
- Scott Hanselman

Of course, as some internal naysayers are right to say, nayly, these charts are invalid as they are inside the HanselBubble where (they say, these sayers of nay) that we all run Chrome 99 and Beta Builds of Windows 7+1.

Nonsense! I say. It's always interesting to see what the user demographic is. With that, to the charts! First, the big one, Visits by Browser.

Chrome 35%, Firefox 28%, IE 22%, Safari 5% and Opera 2% with a bunch of random stuff that doesn't matter.

Interesting, almost looks like the Google Logo. You've got the big 3 in there almost with 1/3 each, but Chrome is ahead and IE and Firefox are more like 1/4 each. We made sure this blogs and works OK on the top 90% of the browsers that hit it and it should look OK on the rest.

Now, let's drill in. First, Chrome:

Chrome v12 and v13 take up over 50% of the pie

Looks like Chrome's auto-updating strategy sure works. I do worry myself, sometimes, that a security bug will sneak in to one of my thrice-daily Chrome updates, but we'll see. There's a balance between security and stability and new features. I hope they've found it. Everyone is basically on Chrome 12 or 13 it seems. I'm on 15 'cause I'm a canary.

What about Firefox?

Firefox 5 has 58% with 3.6 at 10% and 6 at 8.7%

Nearly 60% on 5.0, but 6.0 is doing pretty well given it JUST came out. I'm a little surprised at the Firefox 3.6 numbers. 10% is a little high, IMHO, but there are those that believe that was a great release and have stuck with it.

Next, Internet Explorer:

IE9 with 43%, IE8 with 42%, IE7 with 11% and IE6 with 2.44% 

Big numbers for IE9. I assume that's because Windows 7 isn't Windows Vista and folks are really liking it. Also possibly that folks who read this blog do Microsoft tech and have installed IE9 to be on the latest stuff. Kudos to Jeremy for getting this site's markup to work on IE9, IE8 and IE7. I'm afraid not for you guys on IE6. I'm sorry your corporation is oppressing you.

Screen Resolution

Y'all got some LARGE monitors and high-resolution displays! 90+% of my readers are running screens wider than 1024x768.

90% of my readers are running larger than 1024x768

One could argue from these numbers that I could target 1280 as a browser width, but with this new redesign Jeremy and I decided to support not only mobile (decently, although we need to take a deeper look at how to make the fonts more readable) but also really small resolutions on netbooks and stuff. Here's this site resized to about 800x700:

My site resized really small. I've removed the right rail and expanded the text.

And still this same blog, but now resized to about 1500x1500:

My site resized really big. Looks good.

Mobile

On the Mobile side, I had about 15k PV from an Android Browser version which is almost as much as Opera on my site, nearly 2%. This explains all the emails I've gotten about a bad cert issue that only shows up on Android. There's almost 6% Safari, and about half are iOS devices.

86% of the mobile browsers that hit my site have a touch screen. I don't have good percentage numbers but I do have this sorted list of visits by mobile device. I know that about 8% of the browsers that hit my site are mobile.

iPhone 21k Visits, iPad 17k Visits, Unknown 6k, iPod Touch 1.4k

I don't obsess over these stats; I maybe look at them twice a year or when making large decisions. It IS useful for you, Dear Reader, to take a look at your own readership. Perhaps they are Cupcake baking Moms, or Linux Hackers, or Fly-fishing Retirees. What browsers do they run? What resolutions are their screens? How fast are their connections? Does your website or blog know who your audience is and cater to not only their minds but also their browsers?

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

How to REALLY hurt yourself with PSEXEC - Deleting the Undeletable Registry Key and More

August 19, '11 Comments [19] Posted in Tools
Sponsored By

A while back I installed some crazy open source network adapter virtualization software. Don't ask. It was a bad idea and I happily clicked Yes Yes Yes, Oh Yes, I Know, Hurt Me, Warning, Sure, Absolutely, Next, Next, Finish without a thought.

Later, things started acting wonky so I uninstalled it. Unfortunately, their uninstaller didn't so much "uninstall" the program as it "uninstalled the uninstaller then left everything around chilling." This left my system in a really weird state with half-connected phantom network adapters and I was getting some weird hangs. Each time I uninstalled these 7 (!) phantom network adapters, they'd be back on a reboot. Clearing removing them with the Device Manager UI wasn't working  for me.

At this point it was either time for a repave of the machine (basically a complete reinstall since I got it into a bad state) or running around in the registry and deleting these phantom adapters. Since I'm supposed to be technical, and since I was ready to reinstall it wouldn't hurt if I messed up the system, I fired up regedit.exe. I ran it as Administrator so I could have (I thought) the ability to delete anything.

I searched for the brand of the adapter I was wanting to delete, and when I started deleting stuff I was getting smacked with
"Access Denied." What?!? I'm the all powerful Administrator! sudo make me a sandwich!

Administrator isn't all powerful. There are other, deeper users like SYSTEM that have access to things Administrator (rightfully) doesn't. Considering that I am trying to removing low level network stuff it was good that I was being stopped.

That said, what's the best way to motivate an engineer? Tell him something  isn't possible. I hate getting Access Denied. Deny this, I say! So I turned to the SysInternals Tools, specifically PsExec.

If there was one tool that really "takes the safety off the gun," it's PsExec. You can hurt yourself and your system with PsExec in ways where you'll not realize until it's too late. There aren't enough words with big enough fonts and scary enough evocative stock photography to fully express how dangerous this tool is.

That said, here's cheerfully how to use it! Woohoo!

psexec -s -i regedit.exe

This has to be run as an Administrator. It This line says, "run this command as the SYSTEM account and let the process interact with the desktop." If I look at the Task Manager after running this command, check out regedit.exe:

Oy! Scary! See that RegEdit is running as SYSTEM

At this point, I was able to delete basically anything in the registry. One other way I could possibly delete keys that I couldn't as regular Administrator would be to launch Windows into Safe Mode and try editing from there.

Other awesome things you can do with PsExec include running processes remotely (which is kind what it's doing when I run it as SYSTEM, just all on on machine.) with a Service that gets automatically installed remotely and then runs the processes.

Here's how they do it (it's not a secret):

PsExec allows redirects of the input and output of a remotely started executable through the use of SMB and the hidden $ADMIN share on the remote system. With this share, PsExec uses the Windows Service control Manager API to start the PsExecsvc service on the remote system which creates a named pipe that PsExec communicates with. This named pipe is what allows for input/output redirection back to the system that launched PsExec.

For example:

psexec.exe \\REMOTECOMPUTER –i –u DOMAIN\username –p Password –d yourexe.exe

It's useful to remotely execute things, but it's even more useful to "terminal" (not quite like ssh) into systems like this:

psexec \\remotecomputer cmd.exe

Which means you can run commands on that remote computer as if you were there, in a SSHy way.

C:\>hostname
HANSELMANLAPTOP
C:\>psexec \\REMOTECOMPUTER -u DOMAIN\Administrator cmd.exe
C:\>hostname
REMOTECOMPUTER

Powerful but really useful stuff for when you really don't feel like RDP'ing (Remote Desktop'ing) into a machine to simply run a command.

Be careful out there!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Sponsored By
Hosting By
Dedicated Windows Server Hosting by SherWeb

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.