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

Automation using Powershell

I have an installation proram (Basic MSI) with 20,000 + files, my problem is knowing if I have added all the files compared to what is in the folder. This started me off on Powershell where I now get a list of all the files under a directory structure and compare them to those in my project.....all the files I haven't added are just listed in a text file.

This was a start in the right direction so I thought I'd clear all of my files in my components (except perhaps the key file) and then run a Powershell script to add the file prior to the compile.

If I use VB/VBA/VBScript : (Very simple example) This works a treat and file APSP52.RS is added and I could optionally make it the key as well.

Dim obj As New ISWiAuto16.ISWiProject
x = obj.OpenProject("C:\InstallShield 2010 Projects\test.ism", False)

Set Comps = obj.ISWiComponents

Set Screensobj = Comps("Screens")
Screensobj.AddFile ("C:\TESTFILES\APSP52.RS")
'Screensobj.KeyPathType = 2
'Screensobj.KeyPath = "apsp52.rs"

obj.SaveProject
obj.CloseProject

Set obj = Nothing

But when I do the same thing in Powershell is doen't seem to save the file I don't seem to get any errors.

Where have I one wrong?


cls

$Drive = "C:\"
$BuildFolder = "TESTFILES\SCREENS"
cd $Drive
cd $BuildFolder
echo "Start"
echo "Get file list"
# $files = dir -Recurse | where {$_.psIsContainer -ne $true}
echo "Open poject $($TheInstallshieldProject)"
$TheInstallshieldProject = "C:\InstallShield 2010 Projects\test.ism"


# $oneInstallshieldProject = New-Object -comobject ("ISWiAuto16.ISWiProject")
$oneInstallshieldProject = New-Object -com ISWiAuto16.ISWiProject

$x = $oneInstallshieldProject.OpenProject($TheInstallshieldProject)
echo "File open status : $($x)"
$aComponentCollection = $oneInstallshieldProject.ISWiComponents
$t = $aComponentCollection.count
echo "Component Count : $($t)"

foreach($Component in $aComponentCollection)
{

if ($Component.Name -eq "Screens")
{
# ForEach ($file in $files)
# {
$Component.AddFile("C:\TESTFILES\APSP52.RS")
# }
}
}

$oneInstallshieldProject.SaveProject
$oneInstallshieldProject.CloseProject
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($oneInstallshieldProject)
$oneInstallshieldProject = $null
Labels (1)
0 Kudos
(1) Reply
NeilHayes
Level 5

After much pain I got this to work with just a few line changes....the main problem was the missing ()



$q = $oneInstallshieldProject.SaveProject()

echo "Project saved status : $($x)"
$q= $oneInstallshieldProject.CloseProject()
echo "Project closed status : $($x)"
0 Kudos