Thanks Friedrich!!!

Previously I had added Set Installer Flag function line just above the create shortcut script line, as suggested by you I moved Set Installer Flag function line above, then it worked like magic.