[Incident]: Some users report they are unable to access the case portal. Please see this community notice for more information.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Set File Version to Always Overwrite using an InstallShield Automation Interface script

Set File Version to Always Overwrite using an InstallShield Automation Interface script

Summary

Set  “Always Overwrite“ to all files in a project using an InstallShield Automation Interface script.

Symptoms

In a project which contains a large amount of components and files, where files are frequently added and changed, setting Always Overwrite for each file manually is problematic and time consuming.

Resolution

It is possible to use InstallShield's Automation Interface functionality to automate this process.  The example below uses  VBScript code to set the "Always Overwrite" setting for all files so that the check box is checked.

You can run the script using a VBS Editor or you can run the script using “wscript.exe” or "cscript.exe" in an Administrator command prompt.

Path to wscript.exe “C:\Windows\System32>wscript.exe”

 

'Create project object for InstallShield 2021
Set pProject  = CreateObject("ISWiAuto27.ISWiProject")
 
'Open project
pProject.OpenProject "C:\InstallShield 2021 Projects\My Project Name-4.ism"

Set pComponent = pProject.ISWiComponents

Msgbox pComponent.Count

For Each pComponent in pProject.ISWiComponents

Set pFile = pComponent.ISWiFiles

MsgBox pFile.Count

'Set OverrideSystemVersion all file component in ISM

For Each pFile In pComponent.ISWiFiles

pFile.OverrideSystemVersion="TRUE"
'pFile.Version ="10.2.30.55"
 pFile.Version = "65535.0.0.0"
pFile.OverrideSystemLanguage="1041"
pFile.OverrideSystemAttributes = "TRUE"

Next

Next

pProject.SaveProject

'Adding a Product Config and Release
pProject.AddProductConfig("Prod config").AddRelease("Release")

'Set an existing product configuration
Set productconfig = pProject.ISWiProductConfigs.Item("Prod config")

'Set and existing release
Set Release = productconfig.ISWiReleases("Release")


'Build the release
 Release.Build()

'Save and close
pProject.SaveProject
pProject.CloseProject

 

 

Click here for documentation about the InstallShield Automation Interface.

Click here for documentation about Automation using a Python script.

Click here for documentation about Automation using a PowerShell script.

Was this article helpful? Yes No
No ratings
Comments

thank you very much Varul.

Now we can use the new function always overwrite to Yes from IS2021

 

Dim pProject, ProjectPath

'Create project object for InstallShield 2021
Set pProject = CreateObject("ISWiAuto27.ISWiProject")

'path to Project create 
ProjectPath = "C:\InstallShield 2021 Projects\Test_AlwaysOvewrite.ism"

'-1 = ISMSI Project Type, 9 = pro, 1 = msi
pProject.CreateProject ProjectPath, 1 
'change the -1 to 1 for BMSI project

'Open project
pProject.OpenProject "C:\InstallShield 2021 Projects\Test_AlwaysOvewrite.ism"

Set Feature =pProject.AddFeature("TestFeature")
Set pComponent =pProject.AddComponent("TestComponent")
feature.AttachComponent(pComponent)


'Adding File to Component
Set FileOverwrite=pcomponent.AddFile("C:\Windows\Notepad.exe")

'Setting Key File

pComponent.KeyPathType = 2
pComponent.KeyPath = FileOverwrite.Name

'Overwriting File version
FileOverwrite.AlwaysOverwrite=True
Set release = pProject.AddProductConfig("Product Configuration 1").AddRelease("Release 1")

'Save the project:
  pProject.SaveProject

'Build the release
 release.Build()

'Save and close
pProject.SaveProject

Version history
Last update:
‎Mar 16, 2022 04:03 PM
Updated by:
Contributors