Friday 27 February 2015

Active Setup - Advance Application Packaging

Active Setup


  
Active setup is a process that runs automatically when a user logs in. Active Setup runs for every user belong to that domain\server\machine.

Registry key location :

"HKLM\Software\Microsoft\Active Setup\Installed Components\%APPLICATIONNAME%" &

"HKCU\Software\Microsoft\Active Setup\Installed Components\%APPLICATIONNAME%"

If your application requires installation of files or registry keys on a per-user basis, but your application has no advertised entry points or other triggers to initiate the installation process, then Active Setup is the solution.

To implement Active Setup, you need to package all your user installation requirements into an single installation or executable and point active setup to that executable and point this executable to StubPath entry in active path registry location.

If the HKCU Active Setup registry entry exist or the version number of HKCU is equal to HKLM, then the specified application is executed for the current user.

Ex
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\[ProductCode]]
"StubPath"="%Programdata%\Test\SelfExecute.exe"
"Version"="1,0"



Value for StubPath could be :
1. "%Programdata%\Test\SelfExecute.exe"
2. "msiexec /fpu [ProductCode] /qn"
3. "%Programdata%\Test\SelfExecute.vbs"

When each new user logs on, the operating system compares Active Setup keys between HKLM and HKCU, and runs the StubPath Instruction if the HKCU entry is missing or the version in HKCU is less than HKLM.
So if you ever need to update the ActiveSetup executable, just install a new version, and increment the Version registry key (VALUE2 above) in HKLM.Next time the user logs on, the active setup will run again for that user.

VBS to use versioning of the active setup :

Option Explicit
On Error Resume Next
Dim objShell,intVersion,strStubPath
Set objShell = CreateObject("WScript.Shell")
strStubPath = "msiexec /fou {Package-code} /qn"
objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\StubPath", strStubPath , "REG_SZ"
intVersion = objShell.RegRead("HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\Version")
intVersion = intVersion + 1
objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\Version", intVersion , "REG_SZ"
Set objShell = Nothing

This will increment the HKLM active Setup version by one and when user logsin next time Active setup will run again as HKCU Active Setup entry will have lesser version than HKLM.

I hope this post describe complete Active Setup fundamentals,
Please post your related query’s in comments so that we can add up more knowledge on it.

Thank you for reading.

Thursday 26 February 2015

Adding/Deleting/Importing Registry through VBScript - Advance Application Packaging

PART A : Adding the Registry through VBScript

During packaging we might need to add/write some registry in to system to achive any configuration setting

Ex. Writting a Active setup registry

Option Explicit
On Error Resume Next
Dim objShell
Set objShell = CreateObject("WScript.Shell")
strStubPath = "msiexec /fou {Package-code} /qn"
objShell.RegWrite "HKLM\SOFTWARE\Microsoft\Active Setup\Installed Components\{Package-code}_Install\StubPath", strStubPath , "REG_SZ"
Set objShell = Nothing


PART B : Deleating the Registry through VBScript

Some time there is need to delete some registry entries during package uinstallation to achive clean uninstallation.

To delete single registry key RegDelete function can be used as below,

objShell.RegDelete "HKLM\Software\Innovapost\Installs\Axure Software Solutions\"

but to delete entire registry hive with all sub keys associated inside below VBScript is useful :

On Error Resume Next

set oShell= CreateObject("Wscript.Shell")

set oEnv = oShell.Environment("PROCESS")

oEnv("SEE_MASK_NOZONECHECKS") = 1

Const HKEY_CURRENT_USER = &H80000001
strComputer = "."

strKeyPath0 = "Software\Microsoft\Office\Outlook\Addins\AddinSidePanel.AddinModule\CommandBars"

'PUT THE REGISTRY HIVE WHICH YOU WANT TO DELETE

'FOR MULTIPLE REG HIVES ADD strKeyPath VARIABLE & YOUR NEW REG HIVE PATH & ADD NEW VARIABLE IN FUNCTION CALL TOO.

Set objRegistry = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")

DeleteSubkeys HKEY_CURRENT_USER, strKeypath0
'FUNCTION CALL WITH REGISTRY PATH AS A PARAMETER

Sub DeleteSubkeys(HKEY_CURRENT_USER, strKeyPath)
objRegistry.EnumKey HKEY_CURRENT_USER,strKeyPath,arrSubkeys
If IsArray(arrSubkeys) Then
For Each strSubkey In arrSubkeys
DeleteSubkeys HKEY_CURRENT_USER, strKeyPath & "\" & strSubkey
Next
End If
objRegistry.DeleteKey HKEY_CURRENT_USER, strKeyPath
End Sub

oEnv.Remove("SEE_MASK_NOZONECHECKS")


PART C : Importing the Registry(.reg file) through VBScript

.reg file can be directly imported during installation or uninstallation.


Option Explicit
On Error Resume Next

Dim objShell, ProgramFiles, sRegFile


Set objShell = CreateObject("WScript.Shell”)

ProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%”)

sRegFile = ProgramFiles & "\<MyFolder>\<MyFile>.reg”


'This prompt UAC

objShell.Run "Regedit.exe /s ” & Chr(34) & sRegFile & Chr(34), 0, True

Set objShell = Nothing



'OR USE DIFFERENT WAY :


Option Explicit
On Error Resume Next

Dim objShell, ProgramFiles, sRegFile

Set objShell = CreateObject("WScript.Shell”)
ProgramFiles = objShell.ExpandEnvironmentStrings("%ProgramFiles%”)

sRegFile = ProgramFiles & "\<MyFolder>\<MyFile>.reg”


objShell.Run "Cmd.exe /K REG.EXE IMPORT ” & Chr(34) &sRegFile & Chr(34),0,True


Set objShell = Nothing


Thank you for reading.

Application Packaging in details

As we have disussed Application Packaging 5 Main Phases in Previous blog,
Here I will continue discusstion.

1. Source Validation

Source validation includes following major things

  • Checking application is EXE or MSI

          If MSI - default silent switches available QB,QN etc.
          If EXE we need to find/search proper silent switch for particular EXE Ex /S, silent etc. by using command /? or -? etc.

          How to find silent switches for your application - Courtesy ITNinja
          http://www.itninja.com/blog/view/installshield-setup-silent-installation-switches
         
          General moto of application packaging is to make the Installation Unattended/Silent.

  • Checking where all files ,Registries, Shortcuts are getting installed - accordingly we can decide approach for APP customization as per customer requirement’s.
  • Testing basic functionality of application so that we can make sure created package should behave as per the source provided.





To test the application compatibility  below mentioned applications can be used,
  • Picture Taker
  • Process Monitor
  • Microsoft Application Compatibility Toolkit



Refer below link to find detailed information about Source Validation - Courtesy ITNinja

http://www.itninja.com/blog/view/a-general-approach-to-software-packaging-starting-from-consistent-installer-analysis


2. Application Packaging

Apps packaging involves mainly
Capturing(If Required*) --- Editing --- Transforming --- Testing

As per the Source validation report packager decides approach of packaging.

If the given source is provided is EXE or in loose files format then it requires to be captured and make it in the .msi format.

Source is MSI then MSI have many advantages over EXE.
Install Shield, Wise Package Studio are the basic tools to complete the packaging process.
These tools have many sub tools for different purposes like capturing, validation, comparing etc.

In packaging basic standards are applied. Like junk files, folders, registry keys are removed/added from the package.

If any required remediation is mentioned then that is applied. If there are any post and pre installation configurations mentioned by the customer requirnment doc, any permission settings needs to be included in the package then those are also implemented.

Packaging Life-Cycle



*If the surce is EXE and no MSI is exracting from EXE or no silent switches are available for installation then we proceed with the Capturing. Application can be captured through tools like Installshild or WISE.

3.QUALITY ASSURANCE(QA)

Once application is passed the packaging phase Quality Assurance comes into picture and maintaining the quality of application in terms of customer’s need is very necessary.

In QA basically does a rigorous check for all the general standards and any client specific requirements had should have been implemented.

At the end of QA phase proper documents are maintained like QA Report,Major minor instruction to be followed in terms of customizations made in application.


4.VERIFICATION (VC)

Application Installation and clean uninstallation is neatly checked in this phase.

Most attention is given to All the services, driver gets installed and functions properly as with source.

After creating .msi basic stage is to check whether the application behavior meets client requirements.


5.USER ACCEPTANCE TEST (UAT)

This is the final stage done at client side, as per the requirement request whether the application is running properly or not.

If application is not behaving as per the needs requested then packaging team have to follow the same process again.

Thank you for reading.
We will discuss solving packaging issues,VBScripts for basic workouts etc in m upcoming blog posts.

Thursday 12 February 2015

What is Application Packaging ?


     Application Packaging is kind of process in which Files, Registries and components are customized using some tools and delivered to customer as per their requirnments.

Tools used - Installshild, Wise Package Studio, ORCA etc

    Application packaging involves the preparation of standard, structured software installations targeted for automated deployment.

    Automated installations of applications must fulfill the installation requirements for a specific environment: corporate standards for software usage and desktop design, multiple languages, regional issues, and software-related support issues.




    To build the correct MSI database format packager must collect information about each application.
    Items include executables(EXE), installation instructions, configuration parameters, test instructions, and hardware and software dependencies.
    Once this information is gathered, the packaging effort is designed to produce a Windows Installer–based into a Microsoft OS, packaging engineers must determine whether a new application introduces conflicts.
    The conflict management process is designed to ensure that DLLs do not interfere with each other and that any required application isolation is configured into the MSI database.


Generally Packaging Involves

  1. Source Validation
  2. Packaging
  3. Quality Assurance (QA)
  4. Verification of functionality (VC)
  5. User Acceptance Testing (UAT)

I will be discussing all of this phases in deatils in my upcoming posts.
Thank you!