Wednesday, August 17, 2011

Reinstall missing Grub after install Windows

When you are install windows after installing ubuntu linux version on your pc, no need to install ubuntu linux version again. Follow below instructions to recover grub easily.

1. Boot your computer from Ubuntu live CD

2. Go Places->My Computer

3. Click on the partition you installed ubuntu operating system. Then it will mount.

4. Get the terminal

5. Type this commands in the terminal

    $mount | tail -1

6. You will get result like below

    /dev/sda6 on /media/0d104aff-ec8c-44c8-b811-92b993823444 type ext4 (rw,nosuid,nodev,uhelper=dev

7. Then type this

    $sudo grub-install --root-directory=/media/0d104aff-ec8c-44c8-b811-92b993823444 /dev/sda

(bold texts must be the same)

8. Then Reboot the machine. Here is the command "sudo shutdown -r now" without quotes.

9. Now you can see the grub, but sometime your windows entry may not work. Then go to ubuntu, get the terminal, type this command. You have to provide your password here.

$sudo update-grub

10. End of Task...

Sinhala version

Read more ...

Tuesday, August 16, 2011

Running an Executable and Collecting the Output using C#

Sometimes you may need in the middle of a C# application you want to run an executable and collect the output.  Below sample of code will do what you want.. 

1. Simple method:


Process P = Process.Start("eyeDetect.exe", "hello1.jpg haarcascade_frontalface_alt.xml haarcascade_eye.xml");
P.StartInfo.UseShellExecute = false;
int result = P.ExitCode;
Console.WriteLine("Here is my result " + result);

2. Descriptive Method:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace ConsoleApplication1
    class Program
        static void Main(string[] args)
            StringBuilder Output = new StringBuilder(); 
            using (Process proc = new Process())
                    proc.StartInfo.FileName = "eyeDetect.exe";
                    proc.StartInfo.Arguments = "hello1.jpg haarcascade_frontalface_alt.xml haarcascade_eye.xml";
                    proc.StartInfo.UseShellExecute = false;
                    proc.StartInfo.RedirectStandardOutput = true;
                    proc.StartInfo.RedirectStandardError = true;
                    proc.OutputDataReceived += (o, e) => Output.Append(e.Data).Append(Environment.NewLine);
                    int ExitCode = proc.ExitCode;

Read more ...

How to re install Windows 7 Boot loader

Boot the machine using windows 7 bootable DVD, When you get the second screen go to repair your computer. Select the command prompt and type below commands. 

bootrec /fixmbr 
press enter

bootrec /fixBoot
press enter.
Read more ...