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

Get the value from dialog??

Hi,

Could anyone at least show me how to pass value from a textbox in a dialog to installscripts ?

say like, i have my own dialog which creates a new sql database. How can it pass the value input from the dialog to my custom install script

function CreateDatabase(HWND)
begin
// how to get the value database name from the textbox here ??
end;

Many thanks.
Labels (1)
0 Kudos
(11) Replies
rajeevgc
Level 3

Hi,

Set the textbox value to a property say "DBNAME". Then use the code given below to get the value of the property "DBNAME" using MsiGetProperty function in installscript. The "DbName" identifier in installscript will hold the value of database name from the dialog.:D

function CreateDatabase(HWND)
STRING DbName;
NUMBER nLength;
begin
// how to get the value database name from the textbox here ??

MsiGetProperty(hMSI, "DBNAME", DbName, nLength);

end;

Hope this will help!!!!!
0 Kudos
ChandanOmkar
Level 8

create a dialog with a text box in it. Check the control identifier of the text box.

Go to the install script.
define a macro for your text box.

e.g.

#define TXT_DB_NAME 1302

//here 1302 is your control identifier

again during dialog init use the following code :

case DLG_INIT:
CtrlSetText("AskSQLDBName",TXT_db_NAME, gszSQLDBName);



after that you can use the gszSQLDBName variable anywhere in the code to pass the value. This variable will store the value entered in the text box.


Hope this will help. please let me know if you need any help.
0 Kudos
Not applicable

Thanks for your reply, it helps me alot. But as i've learnt, Basic MSI doesn't have resource ID, so simply no way to achieve that, doesn't it. I'll learn to use Installscript project anyway.

Btw, is there any auto method to create new sql user instead of writing in sql script? Also, samething for creating a windows user and NTFS permission.

Just show me the function name or a solution, i can do the rest.

Thanks again.
0 Kudos
ChandanOmkar
Level 8

See the attached screen shot of the property list of a text box control.
0 Kudos
Not applicable

mine doesn't have that. it's IS premier 2009.
0 Kudos
ChandanOmkar
Level 8

I think you are using the InstallShield for visual studio 2005.

its showing for me here.
Can you tell what project type you are using?
is it installscript msi or basic msi?
0 Kudos
Not applicable

installscript has control ID but basic MSI doesn't. Now I switch to Installscript project.

Btw, do you know how to create a windows user and set a NTFS permission for it on a folder ? Somehow, IS lacks of a decent documentation on many important features, it's hard for us, newbies, to comprehend the system.
0 Kudos
ChandanOmkar
Level 8

you can create the windows user using the following command using command prompt:

NET USER /add

you can either directly execute this command using installscript or you can create a batch file and then execute it through IS using following options:

LaunchAppAndWait( " NET USER ", " /add" , LAAW_OPTION_WAIT);


or

LaunchAppAndWait( " createuser.bat ", " " , LAAW_OPTION_WAIT);


Hope this will help. also i also need to check how to add NTFS perm.

Thanks
0 Kudos
Not applicable

wow, it's great. So LaunchAppAndWait basically can call out other application while running? I can code to add NTFS or win user via my c# app. I'm gonna give it a try.

Thanks alot for your help again.
0 Kudos
bornali
Level 5

matviet,

Your screenshot of the dialog looks just like mine (IS 2009 Pro, basic MSI).
I have checked chandanOmkar's screen shot of property list, but i don't seem to have the 'control identifier' field for text box.
Anyway, in your text box screen shot, i see a field called 'property' which has a value of 'ip'. I have used this field in all my installers to retrieve values.
Make sure the property is capital.. IP or DBNAME or whatever it stands for, and use MsiGetProperty, just like rajeevgc suggested.
MsiGetProperty(hMSI, "DBNAME", DbName, nLength);
where DbName variable now holds the value you read from the property 'DBNAME', which you can now use in rest of your installscript.

cheers!
0 Kudos
ChandanOmkar
Level 8

hey bornali,

the control identifier will not come in basic msi project, so if possible then move ti installscript project.

Thanks
0 Kudos