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

Take path from one window, take text from second

Good day, everyone. I have an urgent task assigned which consists in creating simple installscript-only project, that should have 2 windows: first will promt user to enter a path and create text file in this specified location, while second will promt for text input and save abythins user writes into this text file.

Funny point is that I have small installshield experience (completed tutorials... well, yeah, that's all) and very little programming experience on top of that. As far as i understand, I should first create two custom dialog windows (for example by cloning them from standard ones), then create .rul files with functions, determining behavior for each. After which, include them into main setup.rul and call functions at specific point of time.

Question is - what exact dialog windows|functions|points of time will be best for such task? For reference i searched into "Serial Number Validation Sample Project"m but, honestly, the way it customized default window is just confused me even more... So, please, can anybody help? Thank you.
Labels (1)
0 Kudos
4 Replies
Highlighted
Pilgrim

Re: Take path from one window, take text from second

What you say you want to do can be done pretty easy in InstallScript without any custom dialogs. In fact since you are not installing applications, features, or components, a more general tool like a c# app or even a batch script may even be simpler.

Off the top of my head (without InstallShield handy to check this)
1) Create an InstallScript project, just accept all of the defaults in the new project wizard unless you want to add localization or something.
2) Your description implies that you do not need maintenance (repair, modify, uninstall) support. If correct go to Project\Settings and on the Maintenance tab select 'no uninstall or maintenance'.
3) You can put your code at the top of the OnFirstUIBefore function and then call Exit so that the rest of that default code is never executed, since you are not installing anything.

As part of your InstallShield IDE, in the Start menu (for IS2012 Spring) is a tool that demonstrates all of the built in dialogs. You can look through those choices and select the dialog that is best for your situation. It sounds like you want to:

Call AskPath or SdAskDestPath (there are several other possibilities)

Then call AskText and save that string.

If you need to make layout or text changes to the default dialogs look at your Dialogs view and select which ever dialog you selected above and edit it. (If you decide to use skins make sure you select the skin before you make any dialog layout changes.)

Then do something similar to the functional body of the WriteLine example
http://kb.flexerasoftware.com/doc/Helpnet/installshield14langref/LangrefWriteLine_Example.htm

The actual WriteLine example function prototype is for a MSI custom action which is not what you want. Ignore the function protoype and just use the code in your project to create the file at the path you already collected and write the line of text that you collected.

Then call Exit;
0 Kudos
Highlighted
Pilgrim

Re: Take path from one window, take text from second

Thank you!
Never thought it could be done in such a simple way.
Just for future reference, here's the code I got:


#include "ifx.h"

function OnFirstUIBefore()
number nvFileHandle;
string svResult;
string szTargetPath, szFeatures;
BOOL bLicenseAccepted;

begin

AskPath ("Please choose a path where text file will be saved","c:\\",szTargetPath);

MessageBox("File yourtext.txt wiil be created or overwritten at " +szTargetPath, INFORMATION);

AskText ("Please enter some text to save into that file", "Text goes here", svResult);

OpenFileMode (FILE_MODE_APPEND);

if (CreateFile (nvFileHandle, szTargetPath, "yourtext.txt") < 0) then
MessageBox ("Creating failed.", SEVERE);
abort;
else
if (WriteLine(nvFileHandle, svResult) < 0) then
MessageBox ("Writing failed.", SEVERE);
else
MessageBox ("Success.", INFORMATION);
endif;
endif;

CloseFile (nvFileHandle);

Do(EXIT);

return 0;
end;



It works just great. The only downside is that "do(exit)" part, which makes it look like setup was actually cancelled. But as I guess, that's the safest way to end installshield process without leaving any traces to system. So thank you again.
0 Kudos
Highlighted
Pilgrim

Re: Take path from one window, take text from second

To just exit the setup at the end of your function use:

exit;

If you want it to look like it is being canceled then use:

abort;

I don't recall using Do(Exit) in my many years of InstallScript, but if you want to use it then you can add the OnCanceling handler to your project and modify the behavior if you like.

Phill
0 Kudos
Highlighted
Pilgrim

Re: Take path from one window, take text from second

...And thank you for simple solution again.
I was assured, that if i do "do(exit)", this will make installshield delete it's temp files - meaning leave target system as at the beginning, except for that one created file. But I guess, "exit" and "abort" will do just fine, considering "no maintenance/uninstall" mode is chosen. Nice.
0 Kudos