Thursday, August 23, 2012

Recover Windows 7's Explorer from "No such interface supported" error

Yesterday I experienced a disaster. After I installed and removed Google Drive client, Windows 7 seemed gone crazy: if I click on a document, some times it was opened, sometimes it was not; if I click on an application, nothing happens; if I input the application name, e.g. cmd.exe, in the Run dialog, it always complains "No such interface supported".

I tried almost all the ways I could think / googled of:

  • using Windows restore to restore to the point before Google Drive was removed, it did not work. I could only find 1 restore point, which was wired.
  • try to use some registry cleaner as suggested by some internet posts, it did not work too. (though the way I start the application is a little trick that I'll talk about)
  • re-register all the DLLs on my hard drive, as some posts suggested, which also did not work
Here is the trick to execute an application, when Explorer and Run dialog does not work: it seemed in my case the shell extension to open some of the linked file extensions was still partially working, so I created a file with a non-registered extension and dbl click to open it, then select the application you want to execute. This way, I managed to still execute applications. But applications started from this way could not elevate to administrator mode. Luckily I already made cmd.exe by default run under administrator, so it was not a problem to me.

Back to the problem, I was lucky to have a backup local user account with administrator rights, and I decided to try it out and it was not poisoned as my domain account. So I guess that the problem was the registry database of my domain account. So after I have backup my files, I went to the "advanced system settings" dialog (type the quoted string in the search box on start menu), pressed the "settings" button in the "User profiles" group box, and deleted my domain's profile. All the files under my "C:\Users\MyUser" folder was gone. So do remember backup your files!

This worked for me, use at your own risk.

Wednesday, August 22, 2012

Push back to Gitblit over https, without a valid certificate

Now I have a Gitblit server running, waiting to be connected. The good thing about Gitblit is, you do not even need Git on the server, its package contains a Java implementation of Git. In the long run, you still need it, since the document says git-gc is not properly implemented.

If you already have a Git repository on your local PC, and you want to push it to Gitblit, it's quite simple:

1. Using Gitblit's web GUI to create a new repository, assign share mode. If you want to block anonymous access, make sure you select "authenticated view, clone & push".
2. Open the repository you just created, and you'll see a link started with https://, click the copy to clipboard icon to copy the link to clipboard
3. Start Git console and navigate to your local Git folder
4. Run below command: ( you shall be able to paste the link from clipboard )
  git remote add origin https://yourpcname:yourport/git/yourrepo
  git push origin master
and bang! you'll hit below error:
  "SSL certificate problem, verify that the CA cert is OK."
This is because Git will verify if the server's certificate is a valid certificate. If you are a poor man as I am, you probably don't have a valid certificate. Set an environment variable will make Git skip the verification step (I put this line in the ~/.bashrc file to avoid type it each time)
  $ export GIT_SSL_NO_VERIFY=true 
  $ git push origin master

This will push you master branch to Gitblit. Then you can go to web UI to verify it.

Another way to overcome this certificate issue is to create your own root certificate, import it as trusted root certificate, then create a certificate and sign it with the root certificate. 

Setup Gitblit on windows server 2003

Git is by its nature friendly to *nix systems. So setting up a Git repository on Windows has been really painful: quite several tools need to be integrated, sophisticated steps need to be performed. In short, it's time consuming, error prone, and hard. I tried it once, and do not want to try it again.

Recently I read about (forgot the article, sorry) this new OS project, Gitblit, which really make hosting Git repository on Windows a easy task. It's a Java application, which means it runs on not only *nix, but also Windows! They provide several packages for different usage scenarios, and also good document.

The setup process is very easy:

  • Download the "Gitblit Go" package, unzipped to the folder you plan to hold the software
  • Go to the folder, edit the installService.cmd file and change the "SET ARCH= " line. My server is x86 based, while the default setting is amd86
  • Edit the gitblit.properties, point git.repositoriesFolder to the folder where you hold your Git repositories. Note you should use forward slash even on Windows, e.g C:/GitRepo/. Change server.httpsBindInterface to empty to bind https to all ip addresses. By default it only binds to localhost, which will not allow other computers accessing it
  • Run makekeystore.cmd to create a self-certified key for https
  • Run installService.cmd to install it as a Windows service
  • Start the service and launch browser to navigate to https://yourpcname:8443, and login with admin/admin
  • Change the password of admin immediately.
And you are done!

You will want to examine the gitblit.properties for possible configurations. Most of the items are documented very well so for most items you can just read through the config file and config properly without searching through documents.