When a Windows 2003/XP virtual machine is migrated to Hyper-V, it is not easy to migrate it back to Virtual PC – or VirtualBox. The reason is Hyper-V changes HAL and it is not easy to change the HAL on 2003/XP machine. This issue is solved since windows Vista and up. Starting windows vista, Windows can detect and change HAL. The detect and change HAL option is available in MSConfig->Boot Tab->Advanced Options->Detect HAL

Windows 2008 guest has built in support for Hyper-V; however, when a Windows 2008 image is migrated to Hyper-V, “Detect HAL” option should be selected or Hyper-V drivers won’t work. The following screenshot shows the symptoms of undetected HAL in a windows 2008 guest:

There are straight forward options to start a SQL Server agent job. The options include sp_start_job and “Execute SQL Server Agent Job Task” in SSIS and Maintenance Plans. The issue is that there is no way to start a job and wait until the job is finished. That means the next TSQL or SSIS task starts right after.
I created with the following small stored procedure that becomes handy when it is required to start an Agent Job and wait until it finishes its work.
CREATE PROC [dbo].[usbStartAndMonitorJob]
(
@JobName VARCHAR(200)
)
AS
BEGIN
IF 1<>(SELECT COUNT(*)
FROM
OPENROWSET(
'SQLNCLI', 'Server=localhost;Trusted_Connection=yes;',
'EXEC MSDB.dbo.sp_help_job ')
WHERE name = @JobName)
BEGIN
PRINT 'CANNOT FIND JOB: ' + ISNULL(@JobName,'')
RETURN -1
END
DECLARE @StartTime DATETIME
DECLARE @JobStatus INT
SET @JobStatus = 0
SET @StartTime = GETDATE()
PRINT 'Execute and wait: '+@JobName
EXEC MSDB.dbo.sp_start_job @Job_Name = @JobName
WAITFOR DELAY '00:00:03'
SELECT TOP 1 @JobStatus=current_execution_status
FROM
OPENROWSET(
'SQLNCLI', 'Server=localhost;Trusted_Connection=yes;',
'EXEC MSDB.dbo.sp_help_job ')
WHERE name = @JobName
-- This is just to flush the output messages while waiting
RAISERROR ('', 10,1) WITH NOWAIT
WHILE @JobStatus <> 4
BEGIN
WAITFOR DELAY '00:00:03'
SELECT @JobStatus=current_execution_status
FROM
OPENROWSET(
'SQLNCLI', 'Server=localhost;Trusted_Connection=yes;',
'EXEC MSDB.dbo.sp_help_job ')
WHERE name = @JobName
PRINT 'Afert '+CAST(DATEDIFF(second,@StartTime , GETDATE()) AS VARCHAR)
+' seconds, the status is: '+CAST(@JobStatus AS VARCHAR)
-- This is just to flush the output messages while waiting
RAISERROR ('', 10,1) WITH NOWAIT
END
PRINT 'Job executed ended'
RETURN 0
END
Text editors are essential part of our day to day work and there are many to choose. Perhaps, Visual Studio?s test editor is the first choice for .NET development. Besides that, usually we need a light and fast text editor for the rest of text editing work. Notepad++ (NPP) is my favorite.Here are my top ten reasons why:
- NPP includes most standard features other text editors have (i.e regex search and replace, bookmarks, macros, multi document, multi view, accurate zoom, etc…)
- NPP does rectangular block text selection (Alt-Shift-Arrows or Alt-Mouse) and rectangular text clipboard operations. Rectangular operations becomes even more powerful when used with Edit->Column Editor
- NPP includes syntax highlight and auto complete for popular languages including XML. Also, NPP highlights brace { } [ ] ( ) and indent guideline.
- NPP is slim, low foot print and fast. It is able to load and handle large files
- Includes many handy utilities including:
- HTML and RTF syntax highlight export to file or clipboard
- MIME tools and Base64 encode/decode
- Converts DEC, HEX, OCT, Bin, Text, EBSDIC and ASCII to each other.
- NPP includes a powerful hex/binary editor plug-in. The hex editor is flexible and offers many options. One key switches back and forth between text and HEX view/Edit:
- NPP supports many text file format including Linux, Windows and Mac format:
- NPP monitors file system and notifies user when another program modifies the file being edited
- XCopy is an option. It is included in Portable Apps as well
- The last but not least, It is free!
We don?t get much information about bunch of svchost.exe entries in windows task manager. The KB314056 explains how to use Tasklist /SVC command line at the command prompt to get the details:
The alternative method is adding the command line column to the task manager:

This is not a new technique, but I found it interesting. We can easily manipulate private or protected member of a class by using reflection. It shouldn’t be used in normal circumstances, but it could become a useful hack when we have to use an assembly developed by someone else and some minor manipulations are necessary;) Here is a sample:
using System.Reflection;
namespace PrivateMembersExposed
{
class Program
{
static void Main(string[] args)
{
ClassWithPrivateMembers c = new ClassWithPrivateMembers();
c.PrintThePrivateString();
FieldInfo fieldInfo;
fieldInfo = c.GetType().GetField("privateString", BindingFlags.Instance | BindingFlags.NonPublic);
fieldInfo.SetValue(c, "Yes, I can!");
c.PrintThePrivateString();
System.Console.ReadKey();
}
}
public class ClassWithPrivateMembers
{
public void PrintThePrivateString()
{
System.Console.WriteLine(privateString);
}
private string privateString = "Can you aecess this?";
}
}
Here are items I have in my Visual Studio external tools as little shortcuts:
- Refelctor the Compiled Assembly
- Gacutil the class library
- Put a strong name key in the project directory. Once I use the .snk file, I make it read-only so it won?t be over written by running this command again
Google calculator works perfect. But when we don’t have internet connection or for some complex calculations javascript is the solution! Here is a sample:

So you think it is not powerful enough? Copy and paste this line to your browser’s address bar (one line) :
javascript:for (var x = 0; x <= 4*Math.PI; x+=.5) document.write("********************".substr(0,5+5*Math.sin(x))+ "<br/>");
It works in both IE and Firefox.
When we add a ToolBar to a WonForm form, we can add a set of standard button to the toolbar. I searched my local hard drive for the icon files and I couldn?t find them. After a little investigation I fond that the Icon and Image Library is stored within a zip file at this location:
C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\ VS2005ImageLibrary.zip
There are bunch of nice images and icons inside the zip file. Enjoy!
I ran out of HDD free space last week and I knew it can?t be for real. I used WinDirStat and in a snap I found I have couple of abandoned virtual machines somewhere on my hard drive. WinDirStat efficiently illustrates big files and folders and makes it easy to go through big folders and inspect their contents:
Putting an assembly into GAC is easy, but how about taking a copy of that assembly back? I needed to have Microsoft.Sharepoint.DLL on my development machine to compile a project and I had to take Microsoft.Sharepoint.DLL from the server?s GAC. Assemblies are stored in:
C:\Windows\assembly\GAC\{assemblyname}\{version}__{publickey}\
The easiest way to access that location is using command prompt.