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

Custom Action & Progressbar

Hi:

How can I increment my progressbar when calling a long processing custom action in C#, VBScript, JScript, etc...

Thanks,
Yama
Labels (1)
0 Kudos
(10) Replies
RobertDickau
Flexera Alumni

It takes some determination, but see for example the MSI help topic "Adding Custom Actions to the ProgressBar".

[thread=105165]This ancient thread[/thread] has some information about using VBScript for progress updates.
0 Kudos
yamakamyar
Level 6

I tried to use InstallShield.Interop.Msi.dll located in your default installed location of IS2009 (InstallShield\2009\System folder).

So I created a custom action C#

using InstallShield.Interop; // add reference to: System\InstallShield.Interop.Msi.dll

[Guid("A42E2E16-0062-4998-ABCD-000000000000")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
public class InstallShieldHelpers : IInstallShieldHelpers
{
public InstallShieldHelpers(){}
public void TestingPassingMSIHandleToCSharp(Int32 hanlder)
{
using (Msi.Install install = Msi.CustomActionHandle(handle))
{
install.IncrementProgressBar(5);
// perform my lenghty action here while incrementing progressbar;

}
}
}

[Guid("5E956C79-CFF4-46d7-ABCD-000000000000")]
public interface IInstallShieldHelpers : IDisposable
{
void TestingPassingMSIHandleToCSharp(Int32 hanlder);
}

Now in InstallShield 2009 I add Custom Action
"New Managed Code" -> "Installed with Product"

Execute After ISSetupFilesCleanup

But it does not seem to work...

Any ideas?
Yama
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

I'm unclear why all those Guid attributes and interfaces are being specified - perhaps for use with the InstallScript DotNetCoCreateObject, etc., calls? Getting to the actual problem, what doesn't work - does the action fail to start, does the action fail while running, or does the progress bar just not do what you're expecting? Note that in the thread Robert referenced, the tick counts required to see changes were fairly large.
0 Kudos
yamakamyar
Level 6

Tee problem was resolved... I am definetely going to become a big fan of the Custom Action with Managed Code; though, I am careful on the planning part from this lesson.

What I did was pass the handler as a parameter to my C# public function then used it to loop through items to process. For each item I incremented the progressbar (installer's SetupProgress dialog). Furthermore I was also able to display a CustomData text by specify a small description of what is happening while the progressbar is augmenting by a step. So right below the progressbar a label gets populated with a short description.

So in a nutshell here is the prototype code:

public void RunMyLongProcess(Int32 windowHandle)
{
try
{
int incrementer = 0;
using (Msi.Install install = Msi.CustomActionHandle(windowHandle))
{
install.ResetProgressBar(1500, true, true);
install.IncrementProgressBar(incrementer ++);
Msi.Record record = new Msi.Record(100);

foreach(string fileName in fileNames)
{
Msi.CustomActionHandle(windowHandle).SetProperty("MYPROPERTY", fileName);
record.SetString(1, fileName);
install.ProcessMessage(Msi.InstallMessage.ActionData, record);
// Execute long process here ....
install.IncrementProgressBar(incrementer++);
}
install.IncrementProgressBar(1500);
}
}
catch(Exception e)
{
}
}

There is a lot more to the concept but this introduced me to the basics.

In the couple of months or so I have began working on my company installer with InstallShield I have learn a great deal about your product.

Although I would have loved to get a head start with some of your advanced courses. What would you guys working for the InstallShield proudct suggest as a side reading on Windows Installers?

Hope this helps others looking for the basics I was so eagerly looking...

Thanks.
Yama
0 Kudos
kmlshield
Level 3

Hi,

I only want to create new progress bar. But not to increment the progress bar.

I had created an empty dialog called "Searching" which will be 1st page of my installer. Then, I placed a progress control on the dialog.

When I run my installer, the "Searching" dialog will prompted out. But the progress bar did not run.

DO anyone got idea about this??


Thank you
0 Kudos
scosta0811
Level 2

It's a little bit hacky but it works and involves using autoit to increment the toolbar. Since Ive put it in QA has stopped complaining that the installer "does nothing" or "just stops" for 5 minutes while im running CAs.

http://meninoumbrella.blogspot.com/2009/04/installshield-progress-bar.html
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

Not to rain on an interesting approach, but have you tested this under Vista? I don't know exactly how AutoIt does its magic, but I suspect it may have similar problems to other things we've done that failed on Vista.
0 Kudos
RMartinez
Level 3

Is posible create the custom action from InstallScript?

anyone will help me ...please

I have a Progress bar control but I would like know how is the code in installScript in the custom actions

thanks:confused:
0 Kudos
kobust
Level 2

Is it possible to access a real MSI Handle from managed code? The alleged MSI Handle InstallShield provides is something that appears only to work with their internal InstallShield.Interop.Msi.dll. I would prefer to work directly with the actual MSI Handle (also my assembly is and needs to be strong named and the InstallShield assembly is not signed, so fails to load).

I have tried passing an MsiHandle from an InstallScript custom action to managed code loaded via DotNetCoCreateObject and directly via a managed custom action. In the case of passing the handle from InstallScript, I simply received a (-2) on the other end and was never able to do anything with it. From the managed custom action side, I was never able to call MSI methods like MsiProcessMessage without receiving a (-1) Invalid Handle return code.

Any help would be appreciated,
Todd
0 Kudos
MichaelU
Level 12 Flexeran
Level 12 Flexeran

InstallScript custom actions do have an intentionally incorrect handle, although the reason is mostly historical. You can find the real handle by taking the absolute value of it.

Managed Code Custom Actions should receive the actual MSI handle if they mimic the MSI prototype (they take a single signed or unsigned 32-bit integer; technically unsigned is correct, but it doesn't really matter), or if the MsiHandle token is passed in a custom signature method. You can use this however you like; although InstallShield.Interop.Msi is intended to make things easier, it doesn't do anything fundamentally weird to use the handles. On the other end of the spectrum, I've heard good things about using DTF-built actions with InstallShield.
0 Kudos