T-SQL Simple Timestamp With Leading Zeros
I just had to create a simple string in MS T-SQL that would look like the following:
200812041613
or
yyyymmddhhmm
I solved it this way but I have no idea if this is a good solution (comments welcome):
DECLARE @timestamp AS varchar(12) -- Create Timestamp with leading zeros -- Year SET @timestamp = CONVERT( varchar(4), DATEPART(year, GETDATE() ) ) -- Month IF DATEPART( month, GETDATE() ) < 10 SET @timestamp = @timestamp + '0' + CONVERT( varchar, DATEPART( month, GETDATE() ) ) ELSE SET @timestamp = @timestamp + CONVERT(varchar(2), DATEPART( month, GETDATE() ) ) -- Day IF DATEPART( day, GETDATE() ) < 10 SET @timestamp = @timestamp + '0' + CONVERT(varchar, DATEPART( day, GETDATE() ) ) ELSE SET @timestamp = @timestamp + CONVERT(varchar(2), DATEPART( day, GETDATE() ) ) -- Hour IF DATEPART( hour, GETDATE() ) < 10 SET @timestamp = @timestamp + '0' + CONVERT(varchar, DATEPART( hour, GETDATE() ) ) ELSE SET @timestamp = @timestamp + CONVERT(varchar(2), DATEPART( hour, GETDATE() ) ) -- Minute IF DATEPART( minute, GETDATE() ) < 10 SET @timestamp = @timestamp + '0' + CONVERT(varchar, DATEPART( minute, GETDATE() ) ) ELSE SET @timestamp = @timestamp + CONVERT(varchar(2), DATEPART( minute, GETDATE() ) ) -- Done creating timestamp print N'' + @timestamp
The Bitlocker Odyssey or How I Killed Five Hours of my Time
(…and yours if you are going to read this )
My Windows Vista System had some strange side effects and so I decided to do a reinstall. After having postponed this action many times I finally started yesterday.
First I thought it would be nice to have SP1 slipstreamed into the installation sources but it seems as if Microsoft does not support this anymore. I think they provide slipstreamed sources themselves. Still, there exits two ways to do so: the manual and the vLite way. vLite is the Vista version of nLite. Both are tools to create custom Windows Installation Sources.

Since VLite ist pretty much straight forward I decided to go that way. Still, the process takes around two hours!!! So get a can of tea (I suggest a FTGFOP Darjeeling)…
Once, this process finished I needed a tool to burn the ISO image. I like InfraRecorder which is the first decent GUI to the open source cdrtools I’ve seen.

I did the first try with maximum speed and a second one with the lowest possible speed and both burning processes finished successfully. Still, when launching the installation process I always got the error that it “Cannot find the file D:\Sources\Install.wim. Error code 0×8007000” after I entered the license key. Well, I remember we had burn issues with Vista ISOs and the solution usually was to use a different burn software and to burn at single or double speed but I got pissed and so I continued using the RTM image w/o SP1 I had. Two hours later I had a fresh Vista installation and SP1 was applied manually. And guess what? Of course I didn’t do a backup of the slipstreamed ISO I created and so I couldn’t use it inside a virtual machine to at least test if the slipstreaming process was a success.
Anyway, during installation I left around 1.5 MB of unallocated space on my hard drive because I knew BitLocker would need this as an unencrypted boot partition. But it seemed as if I didn’t leave enough space because when I startet the BitLocker Drive Preparation Tool it said it would shrink my system partition. Since I didn’t want that I directly canceled the process and checked what was wrong. This turned out to be the worst thing I could have done because it left me with an unallocated hard drive space that wasn’t enough for the BitLocker boot partition and a system partition that Vista could not shrink anymore.
Exaleading around a little bit I tried the following:
- Disabled paging and delete pagefile.sys
- Disabled hibernation and deleted hiberfil.sys
- Used JKDefrag (supposed to be able to move the NTFS MFT file)
All the above didn’t work. If you want to try yourself maybe this link is of help.
So what else could I do. Use something like Partition Magic, of course. I used the open source live CD gparted before but this time I tried Parted Magic.

And I tell you it rocks, perfect hardware discovery and after two hours I had a NTFS partition resized with gparted.

Automatically Create IIS Application Pools
Here is the script for the AppPools
@ECHO OFF ECHO. FOR /F "eol=# delims=; tokens=1,2*" %%f in (apppools.txt) DO ( ECHO Creating AppPool "%%f" with user identity "%%g" CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS CREATE "w3svc/AppPools/%%f" IIsApplicationPool CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/WamUserName" "%%g" CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/WamUserPass" "%%h" CSCRIPT %SYSTEMDRIVE%\Inetpub\AdminScripts\ADSUTIL.VBS SET "w3svc/AppPools/%%f/AppPoolIdentityType" 3 ECHO. ) pause
And the correspondign text file:
# # ";"-delimited file to create application pools # Beware of strange characters in password, # though ; should work # Structure is # # AppPool Name ; User ; Password tmpAppPool;tmpUser;tmpPass
Automatically Create IIS Websites
I had to create quite a lot websites on a Microsoft IIS webserver and of course there is a nice scripting solution to it. Here is how I did it:
Batch code:
@ECHO OFF SET webRoot=D:\websites ECHO. ECHO Creating directories ECHO and websites ECHO. FOR /F "eol=# delims=; tokens=1,2*" %%f in (websites.txt) DO ( ECHO Creating Dir %webRoot%\%%f\%%g and website %%g in appPool %%h MD "%webRoot%\%%f\%%g" iisweb /create "%webRoot%\%%f\%%g" "%%g" /i 192.168.228.30 /d %%g.perimeterless.org /ap %%h ECHO. ) pause
and here is the text file that goes with it:
# # ";"-delimited file to create directory structure, # websites and application pools # # Structure is # # Subdirectory ; Sitename ; AppPool testing;test1;DefaultAppPool testing;test2;DefaultAppPool testing;test3;DefaultAppPool
Congratulations to the Internet Explorer 8 Developer Team
In the early beta phase of Microsoft Internet Explorer 7 I posted some improvement thoughts to the official developer newsgroup and never got any response or feedback.
One thing I find pretty important is the option to close only the current tab if you click on the global close ‘X’ in the top most right corner if you have more than one tab open. In IE7 it would only ask you if you really want to close all tabs. If you accidentally clicked on the global close icon but only wanted to close the current tab you had to say ‘No’ and then close the actual tab.
But hey, guess what it looks like in IE8 beta (Konqueror style, woohooo) :
Update:
Wow, we’re really getting somewhere here. Playing around with IE8 beta a little more I discovered that the search box in the upper right corner has a sort auf auto correct mechanism. For example you type ‘target audiecne‘ instead of ‘target audience‘ in the box with Google as your search provider and then Google offers you to correct your search with a link above all the results of your original search query.
If you would like to use the corrected search query in the search box you had to copy’n'paste in the pre IE8 era but now IE8 is doing it for you. I already love this browser.
Virtual PC 2007 VHD: Resize NTFS Windows System Partition
As you may have recognized reading my last post I sometimes use my blog as a Personal Knowledge Management System (PKMS). This post is filed under the same category.
Virtual PC 2007 is a free virtualization product from Microsoft. You can download many M$ Virtual Hard Disk (VHD) files from here
- Go to http://vmtoolkit.com and download the VHD Resizer (btw they also have a tool to convert VMware VMDK images to VHD files)
- Run the tool and open the VHD file you want to resize (make sure its not currently used by a running VM)
- Specify a new VHD file as destination with a type (fixed/dynamic) and a size and click on the button “Resize” (this may take a while so go and get a drink)

- Add the new resized harddisk image to your virtual machine as second/third HD and boot into it with the original small VHD as system disk.

- VERY IMPORTANT: Use “Computer Management” -> “Disk Management” to assign a drive letter to the second/third HD(otherwise
dispartwill not work)

- Now open a CMD console and type
diskpartto get into the interactive mode of the partition utlitiy. The tool is part of Windows XP / 2003 and later and may be downloaded for Win 2000 - type
list volumeto display the list of available volumes in your system - type
select [volume ID](where [volume ID] either is the drive letter or the number given by thelist volumecommand - type
extend

- Shutdown the system
- Use the extended HD as your primary VHD file in your virtual machine configuration and remove the original (small) VHD file from your setup
- Boot the virtual machine and download lots of movies in HD quality to fill up the new space
Direct access to Windows "Network Connections"
On my own account (just a personal reminder):
Press
[Win] (+ [R])
then type
ncpa.cpl
Self decrypting executables the 7-Zip way
Everybody needs to transmit a file to a friend, colleague, etc. in the most possible secure manner once in a while. A cool feature I got to know with the PGP Desktop product line is a self decrypting executable (PGP calls them Self Decrypting Archives (SDA)). You simply use a symmetric encryption algortihm with a password and the tool generates an executable that will decrypt itself once the correct password is given. This password usually is transmitted by phone or another communication link different to the one the file is using.
With one of the latest versions of 7-Zip (my Windows compression tool of choice btw) came a new feature that one may use to copy this behaviour: encryption of archives. Today 7-Zip uses AES-256 as algorithm to encrypt packed archives. But this is not sufficient, yet. You still need 7-Zip to decrypt the file. Not if you use 7-Zip as compression algorithm and select “Cretae SFX archive”
Another reason to love this cool compression tool.
What Internet Explorer is still missing
It is very important to think out of the box every once in a while. I tend to forget this and if I am discovering something new I am always suprised why I didn’t look for it earlier. This is the case with a neat little add-on for Internet Explorer.
I am the kind of a guy who thinks: “Never touch a default system” or “Keep it simple” . This is the reason why I never install additional software on operating systems unless they add a non-existant feature that I really want. This is why I’d never install “Opera” or “Firefox” on a Microsoft machine. Why should I? I mean there already comes a good browser with it. Except the “Find” feature is really ridiculous. A stupid pop-up with no functionality at all (highlight all, find as you type, etc.).
This is where IE Inline Search enters the stage. I suggest you give it a try. Firefox search feeling on websites (see the search bar on the bottom of the screen). Wooohoooo.
Mount ISO images in Konqueror / Dolphin
I didn’t want to bring up a console every time I had to mount an ISO image. So I browsed the web a lil’ bit and found a good solution for my needs. I am a big fan of context menus or service menus as they are called in KDE. These menus are configured through .desktop files. To create such a file only a few steps are necessary:
- Find out the location of .desktop files
- Learn about the syntax of a .desktop file
- Check the mime type of the file where the context menu should appear
- Some eye candy with Icons and submenus
In the end you will have entries under Actions when you right-click on and ISO image that look somewhat like this:

1. Where are these files?
You can use
kde-config --prefix
to find out where your KDE has been installed. You will then find a folder
/usr/share/apps/konqueror/servicemenus (in my case)
Here you create a file with any name you like it only must end with .desktop
Since there now also is a noob file manager Dolphin there also is a folder
/usr/share/apps/d3lphin/servicemenus
Anyway, I used a symbolic link to only have to configure one file for both apps.
2. File syntax
Mine looks like this:
[Desktop Entry] ServiceTypes=application/x-iso Actions=mountIsoImage;umountIsoImage X-KDE-Submenu=ISO Image [Desktop Action mountIsoImage] Name=Mount Icon=cdrom_mount Exec=kdesu -c 'mount -o loop -t iso9660 %f /mnt/iso' [Desktop Action umountIsoImage] Name=Unmount Icon=cdrom_unmount Exec=kdesu -c 'umount %f'
Here you’ll find a good explanation of the file options.
3. MIME type
As you can see you must declare a ServiceType in the .desktop file. This defines when the context menu should appear. A good way to search for these types is to go to Settings -> Configure Konqueror -> File Associations and use the search feature.
4. Eye candy
You may use you own icon images but if you want to use the system icons I suggest editing a K-Menu entry, clicking on the icon and then using the icon browser to find a name of an icon you like.
REMARK
This is tested with Kubuntu Gutsy Gibbon. But I guess it should also work with other distributions.
IMPROVEMENTS
Instead of using the mount command more or less directly one could use a script to create a temporary folder at the current location where the ISO is then mounted. Unmounting would delete the folder again.





