Ehsanul Haque

Welcome to my personal site & blog

12 November
0Comments

Cannot start Microsoft Office Outlook. Cannot open the Outlook window.

Are you getting the error “Cannot start Microsoft Office Outlook. Cannot open the Outlook window.” when you try to open the MS Office Outlook? If you are then the quick and easy fix it to run the following command from Start > Run:

Outlook.exe /resetnavpane

This command should fix the problem with your MS Office Outlook. It worked for me on Windows XP SP2.

22 June
0Comments

How to delete a locked file in Windows?

Sometimes when you try to delete a file on Windows it says file cannot be delete as it is used by another program; you must close the program to delete the file. Well, almost all the time you actually know which program to close in order to delete the file (also rename the file). But today when I tried to delete a file (which was not open in any program nor did I use this file for over three months) Windows was showing the message. You cannot really say which program or process is using it. So I downloaded Process Explorer from Microsoft’s site which you can use to see which process or program is using the file you are trying to delete.

After you run the Process Explorer go to “Find” menu and click on “Find Handle or DLL …” (Ctrl+F). Type in the file name (full or partial) you are having trouble deleting or renaming and hit Search. Process Explorer will list all the processes or programs using this file. When I searched for the file I was having problem with it showed that the “Explorer” is using it! So what can I do in that case?

From “Task Manager” if I kill the “Explorer” process I cannot browse to the folder so using “Task Manager” I ran “Command Prompt” and from command line I changed directory to the desired location. Typed the command to delete the file “del filename.ext”. I was able to delete the file and then using “Task Manager” I started “Explorer” again. It was easy but “Process Manager” made it easy to find the process. So many hidden stuff that we have on Windows!

13 March
1Comment

“sed”: Find and Replace Command on Linux Command Line

Sometimes we use IDE to find and replace strings in our file(s). IDEs have features to search for a keyword in all the files in a directory and replace with a given string. When you’re on Linux and using command line you can easily do this using the command “sed”.

According to the linux manual (man sed) “sed” is a stream editor which is used to perform basic text transformations on an input stream. With this command you can efficiently find and replace text in one or multiple files or you can keep the original file and make a new file with the replacement text.

To find and replace text in the original file the command is:

sed -i 's/find/replace/g' original.php

In the command above, “-i” option instructs to edit file(s) in place. “s” command attempts to match the pattern space against the supplied “find” string (which is a regular expression pattern). If the match is successful, then that portion of the pattern space which was matched is replaced with “replace” text. “g” is used to specify a global change, i.e. the string will be changed everywhere in the file(s) where it finds them. As mentioned earlier the “find” string is basically a regular expression pattern, and the replacement may contain special character (&) or escapes (\1 through \9) to refer to the corresponding matching sub-expressions in the “find” regular expression.

To find text in a file and output to a different file with the replacement the command is:

sed 's/find/replace/g' original.php > replaced.php

In the last command if you do not specify the output filename, it will simply show the file content on the screen with replaced string. There’s another command (similar to “sed”) which can be used for the same purpose is from perl.

perl -pi -e 's/find/replace/g' original.php

This command will find the word “find” and replace with the word “replace” in original.php. For this command “-p” option assume a loop like “while (<>) { …. }” (which is similar to the option -n but it prints the lines as well). The following option “i” performs the same task as it does for “sed”. Then “-e” says anything after it is a online of program. According to the manual several “-e program” can be used.

18 March
0Comments

Fix booting problems with Windows

Every now and then Windows cannot boot up and says one or more system files required is/are corrupted. In many cases people chooses to reinstall Windows but it is easy to fix the problem with reinstalling Windows. You will need to use Windows Repair Installation option. I am not so sure how many things can be fixed but I will go through the one that I’ve fixed.

While trying to install software my PC turned off due to electricity failure (usual scenario in Bangladesh). Later when I started my PC Windows simply refused to boot up and said one of the file was corrupted. So I inserted my Windows installation CD. CD was booted to take me to the screen where it says I already have Windows installed and gives me option to select whether I want to reinstall or repair. There I entered my administrative password and searched for options by typing “help”. There I found one option called “fixboot” and after running it I exited from repair mood. Then I restarted my PC to start Windows normally.

Steps are as follows:

1. Insert Windows CD
2. Boot with CD
3. Select option to Repair Windows Installation
4. Type in your administrative password (if you have set one)
5. Type “fixboot”
6. Type “exit” to restart your PC

Well after you do that you might find yourself with second part of the problem. This time whenever you will start/restart your PC Windows will ask you to check one/more drive(s). It is always good to go through the checks first time after fixing boot problem. But sometimes it never stops. Windows refers this problem as “setting dirty bit”. The thing happens here is when Windows starts, kernel calls autochk.exe which checks for the dirty bit. If it finds one then Windows asks you to check your disk. To fix this problem we will need to unset the dirty bit on the volume that Windows asks you to check through. Following are the steps:

After starting Windows:
1. Go to Command Prompt, Start > Run > cmd
2. Type in the command “fsutil dirty query f:” Here f: is the troubled drive and running this command will tell you whether this drive is dirty or not. It will simply say “The volume is dirty”.
3. Type the next command (if system reports the drive as dirty) “chkntfs /X f:” Here /X is instructing Windows not to check this drive on next boot up.
4. Restart your PC and you should not be asked to recheck your drive
5. After Windows starts go to Command Prompt
6. Type “chkdsk /f /r f:” Here you will be checking the drive manually. This check disk process completes in 5 stages and should be able to unset the dirty bit.
7. Type “fsutil dirty query f:” to check what Windows reports. Windows should say the drive is not dirty anymore.

Hope this will help you solve problems in future. Well if you check this post before encountering the problem.

Thank you

01 February
4Comments

Microsoft Vista – Is it secured enough?

With Microsoft’s latest addition to the OS list, Vista makes its way to market with slogan “WOW”. In fact with the graphical transition this version will blow away anyone’s mind. But for that you must have a good platform, which I think everyone is aware of.

Security has always been an issue with operating system. Latest version of Windows, Vista that is, promises to be stronger in that aspect. Suddenly today I ran into an article which was really interesting. MS Vista has voice recognition capability for performing commands. That means user can speak any command through a microphone.

A question before I proceed. Are you tired of unwanted pop-up window ads? Well, here is a latest challenge for everyone. A website can have some audio clips which will start playing once you visit the site, which can in fact (if speech is clear) can shutdown your PC! A voice command like “Shutdown” can play and your Vista running PC will cleverly turn off. Awesome! Isn’t it?

I am not sure if MS Vista has voice authorising system or not – which may prevent this from happening. Only your voice can run your PC. Hopefully it does.

Have fun with Vista!

18 September
2Comments

Ruby on Rails :: Installation and Startup

Windows Installation steps for Ruby on Rails

You will have to download Ruby installer – click here – and run the installer.

Now next step is to install Rails and to do that go to Command Prompt [Start > Run > cmd]. Run the following command:

gem install rails -remote

This command will look for appropriate version of Rails for the Ruby, download it for installation. This installation process will give some options, select Y for all the givens.

Setup an empty Rails application

To setup a blank/empty Rails application open command prompt and navigate to your project directory:

cd D:/projects/ror/

Now let’s say we want to name our first Ruby on Rails web application “fror” [First Ruby on Rails]. To do so run the following command:

rails fror

This will create a directory called “fror” containing complete directory tree of folders and files for the Rails application.

Test our first Rails application

From the command prompt navigate into the directory that we have just created “fror” and type the following command to start built-in web server, WEBrick:

ruby script/server

Now try to run the URL http : // localhost : 3000/ and this should give you a message like “Welcome aboard”.