Friday, 23 May 2014

Implementing PowerShell Commands in the Windows Installer

Create the PowerShell Commands in the .ps1 file.

For Example:
AppV_Client_Settings.ps1


Import-Module appvclient
Add-AppvPublishingServer -Name AppVServer -URL http://abc.local:8001
Set-AppvClientConfiguration -EnablePackageScripts 1

Create a VBScript to execute the .ps1 file using a Custom action.
For Example:
AppVClientConfiguration.vbs

'==========================================================================
'
' DESCRIPTION: To Add App-V client configuration settings using Powershell commands
'
' NAME: AppVClientConfiguration.vbs
'
' AUTHOR: Gnanamani P
'
' AMENDED :
'
' DATE  : 11/12/2013
'
' USAGE: To Add App-V client configuration settings using Powershell commands
'
' PREREQ:
'
' COMMENT: Script should be called in Defferred execution in System context and in 64bit mode
'
'==========================================================================
Option Explicit
Dim objShell, objFSO
Dim strScriptPath, strWindir, ireturn, strCommand1, strCommand2

Set objShell = CreateObject("Wscript.Shell")
Set objFSO = CreateObject("Scripting.FileSystemObject")

strScriptPath=objShell.ExpandEnvironmentStrings("%ProgramFiles(x86)%") &"\AppVClientConfig\5.0\"
strWindir = objShell.ExpandEnvironmentStrings("%windir%")


If objFSO.FileExists(strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe") Then
strCommand1= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe set-executionpolicy remotesigned -force"
ireturn = objShell.run(strCommand1,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: Powershell RemoteSigned Policy added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting Powershell RemoteSigned Policy. Return: " & ireturn
End if

strCommand2= strWindir & "\system32\WindowsPowerShell\v1.0\powershell.exe –file " & Chr(34) & strScriptPath & "AppV_Client_Settings.ps1" & Chr(34)
ireturn = objShell.run(strCommand2,0,True)
If ireturn = 0 then
AddToMsiLog "AppVClient_Config: AppvClient Module, Client Configuration and Publishing server added. Return: " & ireturn
else
AddToMsiLog "AppVClient_Config: Error setting AppvClient Module, Client Configuration and Publishing server. Return: " & ireturn
End if
Else
AddToMsiLog "Powershell.exe not found in the machine. App-V Client configurations are not added..."
End if

Private Sub AddToMsiLog(strMessage)
Dim objRecord, errMsiMessageTypeInfo
errMsiMessageTypeInfo = &H04000000
Set objRecord = Session.Installer.CreateRecord(1)
objRecord.StringData(1) = strMessage
Session.Message errMsiMessageTypeInfo, objRecord
Set objRecord = Nothing
End Sub


Include the AppV_Client_Settings.ps1 file here "C:\Program Files (x86)\AppVClientConfig\5.0\" in the MSI (for the above VBScript)

Include a Custom Action as below.


Content Disclaimer: Use my blog at your own risk. I’m not responsible for your use of the information contained in or linked from these web pages. This information is being given to you gratuitously and there is no agreement or understanding between you and me regarding your use.

Set a Default Language in InstallShield Setup.ini

When the response file (.iss) is created for the Install Shield setup.exe, the language settings are not getting captured. And the silent installation with the response, always installs the product with the default language which is English in the below screen.


To fix this and change the default language to some other language, the setup.ini file can be utilized.

Original Language Setting in Setup.ini
[Languages]
Default=0x0409
Supported=0x0804,0x0405,0x0406,0x0413,0x0409,0x040c,0x0407,0x0410,0x0412,0x0414,0x0419,0x040a,0x041d,0x041f
RequireExactLangMatch=0x0404,0x0804
RTLLangs=0x0401,0x040d

[0x0409]
0x0409=English (United States)
0x0411=Japanese
0x0401=Arabic (Saudi Arabia)
0x042d=Basque
0x0402=Bulgarian
0x0403=Catalan
0x0804=Chinese (PRC)
0x0404=Chinese (Taiwan)
0x041a=Croatian
0x0405=Czech
0x0406=Danish
0x0413=Dutch (Netherlands)
0x040b=Finnish
0x0c0c=French (Canada)
0x040c=French (France)
0x0407=German (Germany)
0x0408=Greek
0x040d=Hebrew
0x040e=Hungarian
0x0421=Indonesian
0x0410=Italian (Italy)
0x0412=Korean
0x0414=Norwegian (Bokmal)
0x0415=Polish
0x0416=Portuguese (Brazil)
0x0816=Portuguese (Portugal)
0x0418=Romanian
0x0419=Russian
0x0c1a=Serbian (Cyrillic)
0x041b=Slovak
0x0424=Slovenian
0x040a=Spanish (Traditional Sort)
0x041d=Swedish
0x041e=Thai
0x041f=Turkish

Modified Setup.ini for French
[Languages]
Default=0x040c
Supported=0x040c
RequireExactLangMatch=0x040c
RTLLangs=0x040c

[0x040c]
0x040c=French (France)

Content Disclaimer: Use my blog at your own risk. I’m not responsible for your use of the information contained in or linked from these web pages. This information is being given to you gratuitously and there is no agreement or understanding between you and me regarding your use.