December 25, 2012

Combining Uninstall / Change on same button in ARP Panell

Have you ever noticed that double-clicking any program / entry in Add / Remove Programs panel triggers Uninstallation and the application will be removed completely? The user does not have choice to select the options from the maintenance mode window. I have observed this behaviour with Installers created in Wise as well as InstallShield.
This article focus on the limitation associated with this behaviour in InstallShield Basic MSI project and provides a workaround for the same.

Further exploration unveiled that for some applications, the default action (bolded item) is "Uninstall/Change", where as a Basic MSI project created in InstallShield has 3 options as "Uninstall", "Change" and "Repair" and the default (in Bold) action is "Uninstall". My current case is to have "Uninstall/Change" option for our software instead of 3 Options.

For this InstallShield provided a solution with a disclaimer that this has not been tested at their end! But the solution worked like a charm for our application and hence would like to share it ..

By default, Windows Installer allows the creation of the “Repair”, “Change” and “Uninstall” buttons in order to maintain your application. The downside of this method is that the “Repair” and “Uninstall” actions are done in a basic user interface. There is no direct method available in InstallShield to achieve this. But tweaking some registry entries, you can make changes in display of ARP. You can make appropriate backup of registry and then try it.

For displaying Uninstall\Change on same button in ARP, disable all display options under General information->Add/Remove programs.

In the registry options, create the following registry key under the Current User/ Local Machine hive:

Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApplication

where MyApplication is the Product Name you assigned for them.

In MyApplication registry key, create the following registry entries..

Name
Type
Data
DisplayIcon             
REG_SZ                
[SystemFolder]msiexec.exe
DisplayName             
REG_SZ                
[ProductName]
HelpLink                
REG_SZ                
[ARPHELPLINK]
InstallLocation         
REG_SZ                
[APPDIR]
Publisher               
REG_SZ                
[Manufacturer]
UninstallPath           
REG_SZ                
[SystemFolder]msiexec.exe /i [ProductCode]
UninstallString         
REG_SZ                
[SystemFolder]msiexec.exe /i [ProductCode]
URLUpdateInfo           
REG_SZ                
[ARPURLINFOABOUT]
DisplayVersion          
REG_SZ                
[ProductVersion]
Language                
REG_DWORD            
[ProductLanguage]
URLUpdateInfo
REG_SZ
[ARPURLUPDATEINFO]
URLInfoAbout
REG_SZ               
[ARPURLINFOABOUT]
Comments
REG_SZ
[ARPCOMMENTS]
 

Then add the ARPSYSTEMCOMPONENT to Property Manager and set the value as 1.

After successful installation, you can view the "Uninstall/Change" button on your application from Add / Remove Programs Panel.

[Note: This information has been verified with a Basic MSI project created in InstallShield 2012 Spring Edition.]

December 14, 2012

Forcefully removing the 'Installation Directory' during uninstallation..

Most frequent defect that is logged against an Application Package is around "the installation directory not deleted during uninstallation" and we all know that based on Windows Installer design, the files / folders that are not created by the installer will not be removed by the installer. But the user would always want a clean system after uninstallatoin :)

So here you go with the approach to remove the installation directory via Direct Editor.

In the following example, I have a Basic MSI Project created using InstallShied 2012 Spring edition and assume that your application would create some files in the installed directory after installation, which would invalidate the removal of installation directory during uninstallation. The same solution applies to InstallScript MSI Project as well.

Take a look at the RemoveFiles table. You can remove specific files and files using wildcards. Once you remove those files, the folder should get removed as well on uninstall.
Something like the following should do the trick:
_MyFilesToRemove, <SomeComponentKey>, *.*, INSTALLDIR, 2

where <SomeComponentKey> is a key to an entry in the Component table. Any component will do, but if there is an .exe that actually creates the binary files, then perhpas you would want to use that .exe's component as you would only want the files to get removed when the corresponding .exe is removed.
Also, you may want to change *.* to *.<SomeSpecificExtension>

[Note: The above solution is basically an excerpt from MartinMarkevics's post in a community website.]

November 24, 2012

Installation is Rolled-back while creating the VirtualDirectory?

We have a Basic MSI Project created in InstallShield 2012 SP1, which packages a Simple .Net web application. First release of the product was gone, the Installation and uninstallation is working fine.
While making some incremental changes to the installer during second release the installer fails to create the Virtual Directory and started rolling back the installation.

Further exploration revealed that the Installation rollback happens while creating a mapping between the IIS Application and Physical path. There can be two reasons that the installation gets rolled-back while creating a mapping between IIS Application and Physical path.

1. If the web.config is in read only the installation will roll back as it can’t edit the file. But I am not attempting to explictly edit the web.config file while creating the virtual directory.
2. If you are trying to map the website to an empty folder then also it will rollback. A valid point:).. why do you want to create a website without any file?

So please make sure that the web.config file's read-only attribute is removed before bundling the file with the installer.

Note: The contents in this article is verified in InstallShield 2012 SP1 Premier Editions with Basic MSI Project.

November 1, 2012

Using Single InstallShield Project for building both 32bit and 64bit Installers..

Earlier days, we started with 32bit installers and continued to install 32bit application on 64bit machine. Later pure 64bit applications became inevitable. So in addition to the existing 32bit installer, we started creating separate Installshield Project for 64bit installers. Hence we have been creating two different InstallShield Project (ism file) for delivering 32bit and 64bit installers. But as the installer feature grows and considering the maintenance overhead spanned across subsequent releases throughout the product's life time, it would be good if we can have a common InstallShield Project file to support 32bit and 64bit installers. This article would be a discourse with a case study rather than the steps involed in creating such an InstallShield Project.

Case Study:

Project Specification:
  • Common InstallShield Project for both 32bit & 64bit installer.
  • Installation directory to be set based on a Pre-Req Software (say MS Office - Outlook's ADDINS folder).
  • Three Features, having couple of files to be delployed based on Component Best Practice. One DLL is common for both 32b & 64b, a DLL specific to 32b and a DLL specific to 64b.
  • Registry entries to be created to store the installation directory and version information.
Steps to create the Installer:
1. Create a New Basic MSI Project and update basic informations like Product Name, Product Version etc., and Leave the Template Summary under General Information -> Summary Information unaltered.
2. Create Features / Components
 
Features
Components
Release Flag
64-Bit Component
Feature 1
 
 
 
 
32b_RegistryComponent
32bFlag
 
 
64b_RegistryComponent
64bFlag
 
 
MyCommonDLL
 
No
Feature 2
 
 
 
 
32b_DLL2.dll
32bFlag
No
Feature 3
 
 
 
 
64b_DLL2.dll
64bFlag
Yes


3. Defining System Search for framing the installation directory
 Create Two System Search as follows
    Read Path from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Outlook\InstallRoot and set its value to OUTLOOK_32B
    Read Path from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\12.0\Outlook\InstallRoot and set its value to OUTLOOK_64B (Select Read the Value from 64bit Registry)
4. Redirecting the installation directory
Any product that needs to be installed usually have its own installation directory or will get deployed into any of the existing product suite's installation directory. Our current example has a set of DLLs that has to be installed onto ADDINS folder under MS Office - Outlook's installation directory. Here is how you can set the installation directory dymanically..
Create two Set Directory  Custom Actions (say Set64bInstallDir and Set32bInstallDir as follows
 
Custom Action Property
Set64bInstallDir
Set32bInstallDir
Directory
INSTALLDIR
INSTALLDIR
Directory Value
[OUTLOOK_64B]\ADDINS
[OUTLOOK_32B]\ADDINS
Install UI Sequence
After CostFinalize
After Set64bInstallDir
Install UI Condition
ISReleaseFlags=”64bFlag” AND NOT Installed
ISReleaseFlags=”32bFlag” AND NOT Installed
Install Exec Sequence
After SetAllUsers
After Set64bInstallDir
Install Exec Condition
ISReleaseFlags=”64bFlag” AND NOT Installed
ISReleaseFlags=”32bFlag” AND NOT Installed

[Note: Alternatively you can also use Set Property custom action to redirect the installation directory.] 

5. Creating 32b / 64b specific Registry Keys
For both 32b_RegistryComponent  & 64b_RegistryComponent  components, create the following keys under HKLM to store the application’s installation directory and version informationHKLM\Software\MyCompany\MyProduct
        InstallDir – [INSTALLDIR]
        Version   -  [ProductVersion]
During installation the property values [INSTALLDIR], [ProductVersion] will be resolved into the original values.
The only difference here is to Set 64-Bit Component to YES for 64b component.
6. Release Configurations / flags
     Create two release configurations (say 32bReleaseConfig & 64bReleaseConfig) using Release Wizard. Set the values as follows for both the releases.

 
64 bit
32 bit
Product Configuration Flags
64bFlag
32bFlag
Template Summary
x64,1033
x86,1033

Now you have are ready with the common InstallShield project, which will created two different installers for 32-Bit and 64-Bit. Here you go with some tips if you Want to avoid 32bit installation on 64bit machine when you maintain a single project for both 32bit and 64bit? 

Note: This article applies to Basic MSI Project using InstallShield 2012 Premier Edition but should work in upcoming versions of InstallShield as well.

October 20, 2012

Want to avoid 32bit installation on 64bit machine when you maintain a single project for both 32bit and 64bit?

If you are looking to maintain single project for 32bit and 64bit installers and want to avoid 32bit installation on the 64bit machine. You can do it using the following steps.

Step1: InstallScript function needs to be created. As follows

 // Function Delaration
export prototype MyFunction(HWND);

 // Function Definition
function MyFunction(hMSI)
// To Do: Declare local variables.
NUMBER nvSize;
begin
nvSize = 255;     
MsiGetProperty (hMSI, "VersionNT64", svVersionNT64, nvSize);
//MessageBox(svVersionNT64, WARNING);
if ( svVersionNT64 != "" ) then
                MessageBox(@IDSD_WARNING_64BIT, WARNING);
endif;
end
 
Step2: Define this in you String Table.
IDSD_WARNING_64BIT, WARNING = The 64-bit version of Windows has been detected. Installation of this [Product] on this platform cannot proceed, and will be cancelled. Please install this version of SecureDoc only on a 32-bit version of Windows platform.

Step 3: Create an InstallScript Custom action.
Call the above created function in this custom acation.
This custom action this should called after AppSearch in the Install Exec Sequence with the following condition ISReleaseFlags><"MyReleaseFlag" .

Note: This code sample applies to Basic MSI Projects and verified with InstallShield 2010, 2011. 2012 SP1 and 2012 Spring Edition.

September 26, 2012

EPF - Pension Scheme - A Hidden Gem

Not sure how much Rs 3,250/month would mean to you when you cross 58 yrs.. But here you go with the details on EPF – Pension Scheme
Do you know that there are two elements in EPF- one is called EPF and other is EPS. The EPF is actually for your provided fund and EPS is for your pension. The 12% contribution from your side goes to EPF, but the 12% contribution which your employer makes, out of that 8.33% actually goes in EPS (subject to maximum of Rs 541) and the rest goes into EPF. So understand it this way, a part of your employer contribution actually makes up your pension corpus. But there are some caveats to this.
One is liable for pension only if one has completed the age of 58.
One is liable for pension only if he has completed 10 yrs of service (in case of more than one companies, the EPF should have been transferred, not withdrawn)
The maximum Pension per month is subject to maximum of Rs 3,250 per month.
Lifelong pension is available to the member and upon his death members of the family are entitled for the pension.
More details can be found here..
 
 

September 17, 2012

Uninstallation: AskYesNo/MessageBox is hidden behind the progress bar dialog?

Based on the requirement, you may add a Message Box or Yes / No confirmation dialog to the uninstallation sequence using InstallScript Custom Action. When you try to uninstall the application on a Windows Vista environment, these prompts (modal dialog) will be hidden behind the Screen and you will be waiting indefinitely until you press ALT + TAB to view the same.
To overcome this problem, following InstallScript function can be used.
 // Function Delaration
export prototype MyFunction(HWND);
 // Function Definition
function MyFunction(hMSI)
// To Do: Declare local variables.
HWND hRecord,hInst;
begin

hRecord = MsiCreateRecord(1);
MsiRecordSetString( hRecord, 0, "UninstallMessage");
MsiProcessMessage(hInst, INSTALLMESSAGE_USER|MB_YESNO, hRecord);
MsiCloseHandle(hRecord);
end;
 Note: This code sample applies to Basic MSI Projects and verified with InstallShield 2010, 2011 & 2012 SP1.
 Also kindly refer the below MSDN article regarding MsiProcess message function.

September 7, 2012

TFS - Moving from one Hardware to another

This article focuses on moving an instance of Visual Studio Team Foundation Server from one hardware configuration to another, which is termed as "Restoration based move" in TFS.
A key point here is that the Restoration-based move can be used only when your database and application tier are in the same machine.
Requirements to perform Restoration-based move.
·         Machine must be Windows Server 2008 R2 with enough space for restoring the databases.
·         Machine should have the exact same configuration what old machine has.
·         You must be the user belongs to administrator group in the server.
·         You must be added in the SQL Server login group and should be given the following permissions.
o    Dbcreator
o    Public
o    Security admin
o    Server admin and
o    Sys admin
Steps to be followed.
Assume that the machine names are TFS01 (Old machine name) and TFS02 (New machine name)
Make sure that the current user has sysadmin as well as Admin privilege in the system as well as TFS
         I.            Taking the backups from TFS01.
a.        First we need to take the full backups of all the databases
                                                               i.      Tfs_Configuration
                                                              ii.      Default Collection
                                                            iii.      Tfs_CollectionOne
                                                              v.      Tfs_CollectionTwo and etc
                We have to take up the DefaultCollection database backup also. Because Tfs_Configuration maintains the settings of Default Collection and unique collection id of Default collection. 

       II.            Prepare the new machine TFS02.Install all the required software with only one user.
a.        Get an ESX Server Image or Physical machine with the following configuration
                                                               i.      OS - Windows 2008 R2
                                                              ii.      IIS should be installed
                                                            iii.      Minimum 150GB HDD and subjected to vary based on the TFS Backup Database. Allocate 60GB for C Drive, which will have all software installations. D drive can be used to store database. So it can be 90GB initially and increased if the restoration Database size is Huge.

b.       Install SQL Server 2008 R2
                                                               i.      You will get a prompt to add .Net Framework to core role, if it is not already installed. Click OK.
                                                              ii.      Support Setup Rules should succeed
                                                            iii.      Setup Role -> Go with default “SQL Server Feature Installation”
                                                            iv.      Feature Selection – Select All
                                                              v.      Installation Configuration -> Default Instance
                                                            vi.      Disc Space Requirement -> Click Next
                                                           vii.      Server Configuration -> Select Account Name as Network Service for the following four service
1.    SQL Server Agent
2.    SQL Server Database Engine
3.    SQL Server Analysis Services
4.    SQL Server Reporting Services
And leave other services account name as default.
                                                         viii.      Databse Engine Configuration -> Select Mixed Mode and enter password, add the current user and required domain users.
                                                            ix.      Analyssis Service Configuration -> add current user and required users
                                                              x.      Reporting Services Configuration -> Install the native mode default configuration
                                                            xi.      Continue with the installation.

c.        Install Microsoft Team foundation server 2010. Install only with the current user who is performing the restoration.
                                                               i.      Copy TFS 2010 DVD content from en_visual_studio_team_explorer_2010_x86_dvd_509698.iso to the TFS Server and extract it using WinRAR
                                                              ii.      Run Setup.exe from .\TFS-x64 folder.
                                                            iii.      Select “Team Foundation Server” in the feature selection dialog and click Next, It installs the following
1.    VC 9.0 Runtime (x86)
2.    VC 9.0 Runtime (x64)
3.    VC 10.0 Runtime (x86)
4.    VC 10.0 Runtime (x64)
5.    Microsoft .Net Framework 4.0
6.    .Net Framework 4 Multi-Targeting Pack
7.    Microsoft Team Foundation Server 2010
                                                            iv.      It asks for reboot after Microsoft .Net Framework 4.0 installation. The installer resumes after restart to install .Net Framework 4 Multi-Targeting Pack and Microsoft Team Foundation Server 2010.
                                                              v.      Continue with Configure after TFS installation.
                                                            vi.      Start Wizard from the configuration center.
                                                           vii.      Enter <domain>\TFSService and use the correct password for Account details and test. Then Click Next
                                                         viii.      Readiness checks validate that your system is ready to Configure.
                                                            ix.      If IIS is not installed then you will get the following message

Warning
[ System Checks ] None : VFIREWALL (System Checks\Root\Firewall)
Information
[ Application Tier ] Service will be installed for you: IIS
Information
[ Application Tier ] Windows Authentication has not been configured in Internet Information Services (IIS). If you continue, it will be configured for you.

d.       Configuration takes few minutes, which will install IIS as well.
e.        Change the Visual Studio Team Foundation Background Job Agent logon account to <domain>\TFSService and use the correct password.
     III.            Stop the TFS Services using the Command (use RunAsAdministrator in Win 2k8 R2). C:\Program Files\Microsoft Team Foundation Server 2010\Tools\TfsServiceContrlo.exe QUIESCE
     IV.            Restoring the databases.To restore the database the user should have the same permissions as in the above requirements.
Restore all the databases Tfs_CollectionOne, Tfs_CollectionTwo, Tfs_DefaultCollection and Tfs_Configuration and etc.
[If the Tfs_DefaultCollection backup is not available, MSSQL Management Studio and run the following query 
BACKUP DATABASE Tfs_DefaultCollection
TO DISK='<some path>\Tfs_DefaultCollection.bak'
   Use master]
For the existing database, right click on the DB Name and select Tasks -> Restore and Select Overwrite under Options.
For the new databases, right click on the Database and select Restore Database.
       V.            Prepare the SQL Server to host the databases for Team Foundation Server.
Log on to the server, open a Command Prompt window, and then change directories to Drive:\%programfiles%\ Microsoft Team Foundation Server 2010\Tools.
Type the following command, where ServerName is the name of the instance of SQL Server that hosts the databases for Team Foundation Server, in either ServerName or ServerName\InstanceName format:
TFSConfig PrepSQL /SQLInstance:ServerName
[Note: You will get the following message :
Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_CFG_AT_0927_085559.log
Command: prepSql
TfsConfig - Team Foundation Server Configuration Tool
Copyright (c) Microsoft Corporation. All rights reserved.
SQL Instance ‘
ServerName’ successfully prepared.]
     VI.            Redirect Team Foundation Server to its Databases. We must have to redirect our Team Foundation Service to our Databases if any of the conditions are true.
a.        The TFS_Analysis or the TFS_Warehouse database is hosted on a different server from TFS_Configuration.
b.       You are using a named instance to host your databases.
c.        You have one or more collection databases hosted on a different server from the configuration database.

Run the following command.
TFSConfig RemapDBs DatabaseName:ServerName;TFS_Configuration /SQLInstances:ServerName,ServerName2/AnalysisInstance:ServerName2/AnalysisDatabaseName:DatabaseName
Replace the ServerName with the new TFS server name.(ie TFS2).
For us we can run the command as follows.
TFSConfig RemapDBs DatabaseName:TFS2;TFS_Configuration /SQLInstances:TFS2
This will do all remapping to the Team Foundation Server.
(Note: This command also we have run the from the elevated command prompt.)

   VII.            Change the Ownership of the Moved Databases.We must have to change the ownership of the Moved Databases. For that we need to run TFSConfig Accounts ResetOwner Command. Before running we need to make sure that ,
a.        must be appropriate user in the system
b.       use the same account which the TFS is installed and configured
c.        Must be the member of the TFS administrator group.
d.       And must be the member of sysadmin in SQL Server.
Following is the command we have run with elevated command prompt and change the directory to c:\Program Files\Microsoft Team Foundation Server 2010\Tools.
TFSConfig Accounts /ResetOwner /SQLInstance:ServerName /DatabaseName:DatabaseName
Replace ServerName with TFS2 (New TFS machine) and DatabaseName is TFS_Configuration. After replacing the command will be as follows.
TFSConfig Accounts /ResetOwner /SQLInstance:TFS2 /DatabaseName:Ttf_Configuration
If you specify the configuration database, this command will change the ownership for all of the databases for Team Foundation Server.
[Note: If specified database name is incorrect then, it would show the following error
“Logging sent to file C:\ProgramData\Microsoft\Team Foundation\Server Configuration\Logs\CFG_ACCT_AT_0927_090003.log
Command: accounts
TfsConfig - Team Foundation Server Configuration Tool
Copyright (c) Microsoft Corporation. All rights reserved.
Validating Inputs
TF246017: Team Foundation Server could not connect to the database. Verify that the server that is hosting the database is operational, and that network problems are not blocking communication with the server.”]
 VIII.            Update all the service Accounts.We must have to update the service account for Team Foundation Server (TFSService) and the data sources account (TFSReports). Even if these accounts have not changed, you must update the information to help ensure that the identity and the format of the accounts are appropriate for the new server.

To update the service Account
1.    Open a Command Prompt window, and change directories to c:\Program Files\Microsoft Team Foundation Server 2010\Tools
2.       At the command prompt, type the following command to add the service account for Team Foundation, where DatabaseName is the name of the configuration database (by default, TFS_Configuration):
TfsConfig Accounts /add /AccountType: ApplicationTier /account:AccountName /SQLInstance:ServerName/DatabaseName:DatabaseName
In the above command replace ServerName with TFS2, DataseName as Tfs_Configuration and AccountName as <domain>\TFSService. After replacing the command will be as follows.
TfsConfig Accounts /add /AccountType:ApplicationTier /account:SWG\TFSService /SQLInstance:TFS2 /DatabaseName:Tfs_Configuration
[Note: If the account exists, then you will get “Already a member” message]
3.       At the command prompt, type the following command to add the data sources account:
TfsConfig Accounts /add /AccountType:ReportingDataSource /account:AccountName/SQLInstance:ServerName /DatabaseName:DatabaseName
In the above command replace ServerName with TFS2 And DataseName as Tfs_Configuration. After replacing the command will be as follows.
TfsConfig Accounts /add /AccountType:ReportingDataSource /account:SWG\TFSServer /SQLInstance:TFS2  /DatabaseName:Tfs_Configuration
     IX.            Register the Tfs_Configuration Database to the TFS Server.We must have to register the Tfs_Configuration Database to the new Team Foundation Server. This step is missing from the above given link.TFSConfig registerDB /sqlInstance:TFS2 /databaseName:Tfs_Configuration
[Note: This command will also start the Team Foundation Server Job Agent.]
       X.             Update the URL for the Application Tier Server.
To update the URL in the application Tier Server
·         Open the Team Foundation Server Administrative Console
·         Change to Application Ties in the navigation bar and click on Change URLs
·         Change the URLs accordingly and test
[This might throw an error ]

     XI.            Verify the Users and Permissions using the administrative Console.

   XII.            Connect to the new machine TFS2

Some Challenges you may face :

1)       Installing and configuring TFS. We have to make sure that the current user should have sysadmin permissions and admin privileges in the system as well as TFS also.
2)       We must have to take the backup of Default collection from the old machine.
3)       Uninstallation of the TFS will leave some residues in the database as well as default collection. We must have to remove them manually. For that we have to access the URL from the Internet Explorer and manually delete the Default collection.

This document is prepared on the based of the Link.