Wednesday, April 14, 2010

Create BSOD on Vista and Win7 OS

There are many situation when you would like to generate BSOD on a system to test few of scenarios.

Force Windows Vista to crash to Blue screen:
There is a registry hack that allows you to make Windows Vista crash to a blue screen of death whenever you want.

1. Open REGEDIT.
2. Navigate to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\i8042prt
then click Parameters

3. Double-click on CrashOnCtrlScroll and set the value to 1 to enable this feature.

Restart the computer. Now when you hold down the CTRL key and press the SCROLL LOCK key two times, Windows Vista will automatically crash to a BSOD.
(More Info: click here)

An alternative way to force BSOD in C# --
To crash wondows (any OS):
C# program:
Process[] processes = Process.GetProcesses();
foreach (Process process in processes)
{
process.Kill();
}

Above code is enough to generate BSOD on any windows OS.

Friday, April 2, 2010

Problem launching an application in C# asking to set an Environment variable.

Recently I came acrross an issue where I am using C# Process class to launch an application located in Program files directory. The issue I found is after I called process.start() method a pop up came asking "Please set an environment variable required to run this process smoothly". Worst here is I had already set these environment variable for the application but still my script couldn't run though manualy launching this application has no issue.

Solution: set "process.StartInfo.EnvironmentVariables" will resolve this issue.

example:
Process procss = new Process();
procss.StartInfo.FileName = "Application path";
procss.StartInfo.Arguments = "";
procss.StartInfo.EnvironmentVariables.Add("Variable name", Environment.GetEnvironmentVariable("Variable Name", EnvironmentVariableTarget.Machine));
procss.Start();