Category Archives: microsoft

How to Show Removed Devices in Device Manager

Admit it, sometimes you uninstall hardware without removing the driver first. Sometimes the hardware just dies and Windows makes it “go away.” The problem is, the driver and configuration are still there, and if you were using the default Microsoft drivers, there’s no visible way to uninstall those.

Here’s a workaround:

  1. Obtain an administrative command prompt (Start|All Programs|Accessories, right click on Command Prompt and click Run as Administrator)
  2. At the command prompt, type or paste:
    set devmgr_show_nonpresent_devices=1
  3. Then type:
    devmgmt.msc
  4. This will pop up a normal-looking Device Manager, in the menu of which click View|Show Hidden Devices
  5. Expand the relevant part of the tree and (with care) uninstall away!

How to Connect Process ID to Application Pool in IIS

Under IIS6, you used to be able to run this .vbs script at the command line to list all the running app pools and view their Proc Ids:

c:\windows\system32\iisapp.vbs

That script isn’t shipped with IIS7, and it wouldn’t run anyway without modification and the “IIS6 Management Compatibility” installed.  Instead, you can use appcmd.exe to obtain similar information using this command line:

C:\Windows\System32\inetsrv\appcmd list wp

Note, you will need to run the command line as administrator and be in one of the directories where appcmd.exe esists.  I used the 32-bit example here, but on my 64-bit Windows 7 and Server 2008 machines, appcmd.exe exists in both of these directories and produces the same results:

C:\Windows\System32\inetsrv

C:\Windows\SysWOW64\inetsrv

Remote Desktop when all Terminal Services Connections are in Use

This comes up more often than we’d like. And while I’d love Microsoft to fix this and allow unlimited Remote Desktop connections to a server, it doesn’t seem like it’s going to happen. If you get the dreaded “The terminal server has exceeded the maximum number of allowed connections” message, here’s how you can force connect and boot someone else:

Mstsc /v:192.168.0.x /admin /F

It used to be /console instead of /admin, but that went away in XP SP3.

But let’s be clear on what the real fix here is: Microsoft needs to release the 2-user limit on administrator connections for servers that are never going to be used as interactive applications servers. If I’m setting up a new web server or SQL server, there’s no reason I shouldn’t be able to have three or five or 10 administrators logged in at once.

Invalid Viewstate errors in ScriptResource.axd and WebResource.axd

I’ve done the requisite google searching on this one and can’t find a solution, so I’m posting about it in case anyone has an answer…

The basic problem is, I have an ASP.NET Dynamic Data web site that is experiencing occassional “Invalid viewstate errors” in the ScriptResource.axd or WebResource.axd javascript includes on the page. In almost all cases these are due to the URL of the include being corrupted with HTML or other text from the page. That is, instead of the normal “d” and “t” parameters in the querystring, I see something like this (as reported by my custom error handler in global.asax, which emails me a report for every Application_Error event):

http://domain-omitted/ScriptResource.axd?d=w0PmGeT7CMNAKpp-4k5pBNkf0bD1315QQFyhtn4142pWyyhkp5lhqQR6XcoT1lgNSX5Cdw8Q6uPcgDBOu4CSX-e3-cB38lN5S211HGUect<span class=

Querystring:
d=w0PmGeT7CMNAKpp-4k5pBNkf0bD1315QQFyhtn4142pWyyhkp5lhqQR6XcoT1lgNSX5Cdw8Q6uPcgDBOu4CSX-e3-cB38lN5S211HGUect%3cspan+class%3d

I have not been able to replicate this in testing, but in the field, where we have the application running exclusively on IE8 clients, we are seeing this behavior. I’ve read that this could have something to do with IE8’s parsing engine (Trident/4.0). I’ve validated my page using w3c (document type: XHTML 1.0 Transitional). There are a couple of attribute validations I can’t solve, but they’re for stuff like border=”0″ in something generated by the .NET platform (which isn’t actually sending border=”0″ but rather ‘style=”border-width:0px;”‘ as part of an asp:Button… more weirdness). I’ve made sure that all my local javascript is enclosed in XML data blocks as was suggested by some of the forum posts on this topic.

Server is up to date with Windows Server 2003 Standard x64, .NET Framework 3.5 SP1 with family updates installed.

Anyone have any further suggestions?

Can I Has Layout?

Just got bitten by the IE7 (or IE8 “compatability view”) has layout bug yet again, so posting it…

Basically, in the IE7/IE8cv you can only check .clientHeight on elements where hasLayout==true. If your clientHeight is always returning 0, chances are you don’t have layout. The easiest way to get layout? Set display=”inline-block”. Per:

http://bytes.com/groups/javascript/564442-ie-clientheight-problem

And that article points to this one, which is pretty much the definitive source (top Google hit!):

http://www.satzansatz.de/cssd/onhavinglayout.html

height:1% is what I ended up using to make a resizable div “hasLayout.”

display: inline-block makes the div not size to the window horizontally, which didn’t work for my purpose.

I tried using overflow:hidden, but that doesn’t help in IE6.

Stored Procedure to Generate INSERT Statements for All Table Rows Under SQL Server 2005

If you need to create a “data dump” for Microsoft SQL Server, here’s a good free tool:

http://vyaskn.tripod.com/code.htm#inserts

The one thing I haven’t gotten working is any way to automatically add the “SET INDENTITY_INSERT ON/OFF” statements bracketing a table which contains an identity when not using the @ommit_identity = 1 switch. It might be in the comments, I just didn’t dig through it.

I’ll attach them in case that page ever goes away.

SQL 2000 Version

SQL 2005 Version

80/18/2

I’ve come up with a new 80/20 rule for working with Microsoft development products (but it may be universal):

  • The first 80% is easy, if not already done for you.
  • The second 18% is hard, often requiring an undocumented set of hacks to accomplish.
  • The last 2% is impossible.

In my experience, somewhere around 83% you hit diminishing returns. At 97% you’re bleeding from the eyes.