Monday, July 30, 2012

Registry Editor - Adding favorites (bookmarks)

This is a less known but very handy feature when you’re making repeated registry changes to test things, helping you to get very quickly to specific locations.

For example every time I install a new Citrix Client I may have to uninstall the old one first and then go back and change a couple of registry keys (in this case to always send the Windows keys combinations to the remote desktop, pass-through ).

The alternative is to export the entire branch from File menu and re-load at later time – that’ll export all sub-keys and values into a .reg file, which you can edit afterwards with say Notepad to keep only the ones you want to re-load later (just in case others may have changed and will not want to overwrite the entire branch).

Regedit - Add Favorite

Friday, July 27, 2012

The case of… Oracle 11g Listener not starting (Windows)

Just had this problem today where an Oracle 11g Listener wasn’t starting up and when eventually did start listening on port 1521, it wasn’t taking client connections! The odd part is that as far as I know nothing was changed, either software or network configuration, so why all this?! lsnctrl status was showing this error:
C:\oracle\product\11.1.0\db_1\BIN>LSNRCTL.EXE status
 
LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 27-JUL-2012 02:51:26
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.domain.com)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   32-bit Windows Error: 61: Unknown error
Focusing with Process Monitor (procmon) on TNSLSNR.exe showed that it was trying to write to the listener.log file. Right-click the file and choose Jump To… brought the file in Explorer, wow, the log file is 4 GB?! Stopping the listener service, removing the log file and restarting the listener service, services are back to normal now!
C:\oracle\product\11.1.0\db_1\BIN>LSNRCTL.EXE status
 
LSNRCTL for 32-bit Windows: Version 11.1.0.6.0 - Production on 27-JUL-2012 02:52:49
Copyright (c) 1991, 2007, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=server.domain.com)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for 32-bit Windows: Version 11.1.0.6.0 - Production
Start Date                27-JUL-2012 02:52:27
Uptime                    0 days 0 hr. 0 min. 22 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   C:\oracle\product\11.1.0\db_1\network\admin\listener.ora
Listener Log File         c:\oracle\diag\tnslsnr\SERVER\listener\alert\log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=SERVER.domain.com)(PORT=1521)))
Services Summary...
Service "INSTANCE1_XPT" has 1 instance(s).
  Instance "instance1", status READY, has 4 handler(s) for this service...
Service "instance1" has 1 instance(s).
  Instance "instance1", status READY, has 4 handler(s) for this service...
The command completed successfully

I guess now what’s left is trying to figure out how to reduce the amount of logging, it appears that it logs every connection being made, which eventually fills up the log and create the problem.

[…]
27-JUL-2012 03:17:21 * (CONNECT_DATA=(SID=instance1)(CID=(PROGRAM=JDBC Thin Client) 
HOST=__jdbc__)(USER=xxx))) * (ADDRESS=(PROTOCOL=tcp)(HOST=xx.xx.xx.xx)(PORT=53616))
 * establish * instance1* 0
[…]

Monday, July 23, 2012

Auslogics Disk Defrag

I’ve been using Piriform Defraggler for quite a while now and I like it does a good job at defragging your drivers, has an easy to use user interface, can run on a schedule, and last but not least it’s still evolving and new features are added in – one example is the SMART tab, to see information like HDD temperature for which you would need otherwise a separate tool. On the down side I found that it can be slow when defragging larger files and the remaining time calculation is not always accurate and sometimes way off. I occasionally find the need to defrag some larger VM images and not knowing how long is it going to take frustrates me a bit – true, you can leave that for later for an unattended defragmentation and have the software shutdown your PC when done, but still...

There are a few free alternatives out there and Auslogics Disk Defrag is just one of them, but what I like about it is that has similar features that I liked in Defraggler and in a way it looks similar (don’t all disk defrag tools do? :-)  Odd as it might sound though, I like the website (clean and easy to follow) and to me if the same level of attention is given to the software, that’s does it for me. On top of that, I like the fact that when defragging a larger file, it shows the number of clusters going through so you can see the progress being made.

I’m sure Defraggler will improve and I might even switch back someday :-), but for now I think I’ll give Auslogics Disk Defrag a try and use it for a while as the preferred tool.

Note: As with other free software, pay attention to the installation steps as it will ask you whether you want to install additional software like toolbars and the sort, it’s all up to you.

Auslogics Disk Defrag

Friday, July 20, 2012

Java not connecting to Microsoft SQL Server 2008 R2 Express

Although Microsoft SQL Server 2008 R02 Express was configured correctly to accept TCP/IP connections (SQL Server Configuration Manager > SQL Server Network Configuration > Protocols for SQLEXPRESS), a test connection from Squirrel SQL is just hanging with “Connecting…” message.


My context:

Process Explorer showing that SQuirrel SQL (javaw.exe) was in fact it connected on port 1433, but not able to finish the connection process. That was also confirmed by the fact that when restarting SQL Express server, SQuirrel SQL was coming back promptly.


Most of the answers on the Internet will tell you how to configure SQL Express for TCP/IP connections and that you might need to add a rule to the firewall - that wasn’t really necessary in my case as I only needed local connections.

Eventually I found this post on stackoverflow.com where a user reports having similar problems with Java 1.6.0_29:

Related post on Microsoft JDBC team blog:

Updating my environment to use Java 1.6.0_33 solved the problem.

Thursday, July 12, 2012

Microsoft SQL Server 2008 R2 Express and compressed volumes

On the earlier mentioned VM, I’ve compressed the entire volume to save some disk space, after creating the database. As I found later though, my SQL Server database wasn’t coming back online. Taking it offline and then bringing it back online with SQL Server Management Studio the reason became apparent – SQL Server does not allow for active database files to be compressed at file system level!

The file "C:\...\database.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
The file "C:\...\database.ldf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed.
Database 'database' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
ALTER DATABASE statement failed. (Microsoft SQL Server, Error: 5118)

And it appears for a good reason – database performance would be affected by the read/write operations on compressed database files and it could happen unknowingly just it happened to me – someone could compress the volume, performance is affected and everyone will be scrambling what might’ve happened to a production database! The compression was pretty good as well, my 8 GB database was only taking about 2.5 GB of space, you can imagine a much larger database saving a lot of space.

Another important reason is database recovery, all explained below:

In my case, I kept the volume compressed, but uncompressed my two database files (.mdf, .ldf), problem solved. Interestingly enough though, SQL Server doesn’t seem to apply the same restrictions to tempdb and master databases…

Sunday, July 8, 2012

The case of… breaking the WinSXS folder security rights

Just had this problem the other day when having to re-install Microsoft SQL Server 2008 R2 Express (x64) on a Windows 7  SP1 (x64), the setup was failing with the error message:


Microsoft SQL Server 2008 R2 Setup
----------------------------------
An error occurred during the installation of assembly
'Microsoft.VC80.CRT,version="8.0.50727.42",type="win32",processorArchitecture="amd64",publicKeyToken="1fc8b3b9a1e18e3b"'.
Please refer to Help and Support for more information. 

Searching the web for similar it appeared to be failing at installing Microsoft Visual C++ 2005 Redistributable package. Downloading and running the package on its own was showing the same error. After spending a lot of time digging through similar problems on the web with suggested solutions ranging from removing the *vc80* files from %WINDIR%\WinSxS and re-installing the affected packages to running the System Update Readiness Tool for Windows 7, nothing seemed to fix it. Trying a few things myself, bringing some of the related files over from a similar working system (ATL, MFC etc) into %WINDIR%\WinSxS, without much luck; taking traces with ProcMon watching for missing files, nothing.

All until almost giving up, I thought it might be a permission issue – I did remember playing with WinSxX folder recently on that system (more about it below) so filtering again with ProcMon for msiexec.exe and ACCESS DENIED results, revealed this:


msiexec.exe running under SYSTEM account was denied access to %WINDIR%\WinSxS\InstallTemp! Comparing the security for that folder to a similar working system showed that SYSTEM requires full rights there. Manually fixing the rights on that folder the installer has worked fine once again, problem solved.

* * *
Now, to the not so pleasant part where it shows that all this was due to my own stupidity, and hopefully a meaningful lesson for others.
This was a VM with a somewhat limited amount of space and was trying to compress a few larger folders found with WinDirStat (tip: hide Treemap and File types from Options menu, you don’t need them), one of them being %WINDIR%\WinSxS. You can find a lot of forum posts where people complain about it growing to take a lot of space, and other people telling you to stay away from it. In my case, the folder was about 12.5 GB and compressing it reduced it down to ~8 GB, saving quite a bit of space.

How did I do it? TrustedInstaller is the owner of the folder and a local Administrator won’t have the rights to compress – trying to compress it will give you a lot of Access Denied errors and if you ignore them all it won't compress anything. So I came up with these steps:
  • take ownership of the WinSxS folder in Windows Explorer > Properties > Security tab;
  • add my user with full rights and propagate the rights to the child objects;
  • compress folder (Windows Explorer > Properties > General > Advanced);
  • remove my user from the security list;
  • give ownership back to TrustedInstaller (NT Service\TrustedInstaller).

In short this is what happened – normally SYSTEM account has only read/list rights on the WinSxS folder, but on WinSxS\InstallerTemp it has full rights (not inherited). When adding my user and propagating the rights to subfolders, it changed those full rights to read only, making the module installer fail later.

The lesson I guess is, if you are not prepared to pay the price, stay away from that folder. Or maybe otherwise be persistent and experiment to understand what’s going on, but that might take a lot of time and effort, with sometimes very little gain - 4 GB of disk space for almost a day of frustrating trial & error.

Sunday, July 1, 2012

Running a command / application as Local System

Occasionally you may need to run a command or application as Local System, say a service application that doesn’t produce enough log information and fails due to security rights.

One way to do it is by scheduling a command through Windows Task Scheduler, as explained here:
http://blogs.msdn.com/b/adioltean/archive/2004/11/27/271063.aspx?Redirected=true

But I find easier to use psexec.exe from Sysinternals’ PsTools package.
http://technet.microsoft.com/en-us/sysinternals/bb896649.aspx

Not only you can run an application locally, but you can also use it to run it on another machine remotely; run psexec without parameters to get a list of options.

psexec –s cmd.exe

psexec - local system