This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: How to set enviroment value and use it by other function ?
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 19, 2008
09:22 AM
How to set enviroment value and use it by other function ?
Hi all,
I am using Basic MSI project.
I wrote a function which ask the user to provide username and password, I would like to use this user name and password in other functions as well.
Since it is not wise to write it to a file, I would like to know if there is any way to set an environment value and use it in any other function.
if some one could give my example it will be great
Thanks !
Oded
I am using Basic MSI project.
I wrote a function which ask the user to provide username and password, I would like to use this user name and password in other functions as well.
Since it is not wise to write it to a file, I would like to know if there is any way to set an environment value and use it in any other function.
if some one could give my example it will be great
Thanks !
Oded
(5) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 19, 2008
12:23 PM
Perhaps set properties with MsiSetProperty and later read the values back with MsiGetProperty? The documentation and these forums have many examples.
(If you do use properties, you might eventually look into using MsiHiddenProperties to prevent the values from being written to an MSI log file.)
(If you do use properties, you might eventually look into using MsiHiddenProperties to prevent the values from being written to an MSI log file.)
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 20, 2008
03:03 AM
Thanks for the quick reply, I will check it !
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 20, 2008
06:10 AM
Hi again,
Below is my code, there are three functions:
1. GetGlobalUsername - ask the end user to provide username and password and store it using MsiSetProperty.
2. ChangeCredentials - which should configure COM+ application using the information stored at MsiSetProperty
3. Install_services - install services and configure the username which run it.
I was trying using MsiSetProperty and MsiGetProperty but for some reason MMusername and MMpassword are blank 😞 in ChangeCredentials and Install_services.
Since I am new with installshield, and not that sure what I'm doing, I hope someone will be able to assist...
Thanks in advance
Oded
Below is my code, there are three functions:
1. GetGlobalUsername - ask the end user to provide username and password and store it using MsiSetProperty.
2. ChangeCredentials - which should configure COM+ application using the information stored at MsiSetProperty
3. Install_services - install services and configure the username which run it.
I was trying using MsiSetProperty and MsiGetProperty but for some reason MMusername and MMpassword are blank 😞 in ChangeCredentials and Install_services.
Since I am new with installshield, and not that sure what I'm doing, I hope someone will be able to assist...
Thanks in advance
Oded
// Include Ifx.h for built-in InstallScript function prototypes.
#include "Ifx.h"
//******************************
//GLOBAL PROTOTYPE AND FUNCTIONS
//******************************
export prototype GetGlobalUsername(HWND);
export prototype ChangeCredentials(HWND);
export prototype Install_services(HWND);
//global var
NUMBER svresult, defualt, nresult,nsize ;
NUMBER nSize;
STRING MMusername, MMpassword, password, username;
/*----------------------------------------------------------*\
* This script get the user name and password
\*-----------------------------------------------------------*/
function GetGlobalUsername (hMSI)
STRING defualt_user, defult_password,szMsg,szdefult, password1, password2;
begin
ask_username:
szMsg="Specify the user name to be used for running COM+ Applications ans Windows services.The user name should be in the form DOMAIN\\Username." ;
defualt_user="AG\\defualt-user-name";
AskText(szMsg,defualt_user,username);
szMsg="Are you sure you want to use "+username+" as user name?";
if (AskYesNo(szMsg, YES) = NO) then
goto ask_username;
endif;
ask_password:
szMsg="Please specify the password for "+username ;
defult_password="";
EnterPassword(szMsg,defult_password, password1);
szMsg="Please verify the password" ;
szdefult="";
EnterPassword(szMsg,defult_password, password2);
if (password1=password2) then
goto continue;
else
MessageBox ("Password does not match, please enter it again.", INFORMATION);
goto ask_password;
endif;
continue:
password=password1;
//save the username and password in MSI properties
MsiSetProperty (hMSI, "USERNAME",username);
MsiSetProperty (hMSI, "PASSWORD",password);
end;
/*----------------------------------------------------------*\
* This script set the COM+ credentials
\*-----------------------------------------------------------*/
function ChangeCredentials (hMSI)
STRING vbscript, argument;
begin
vbscript ="C:\\MM\\Install\\COM+\\ChangeCredentials.vbs " ;
MsiGetProperty (hMSI, "USERNAME", MMusername, nSize);
MsiGetProperty (hMSI, "PASSWORD", MMpassword, nSize);
argument=MMusername+" "+MMpassword;
//change the Credentials
LaunchAppAndWait ("cscript" ,vbscript+argument, WAIT);
end;
/*----------------------------------------------------------*\
* This script will install the service and configure it
\*-----------------------------------------------------------*/
function Install_services (hMSI)
NUMBER nRootKey, nResult;
STRING SC,CONFIG,ServiceName, ServiceDisplayName, ServiceDescription, ServicePathFile, StartServiceArgs;
BOOL StartService;
begin
//set SC and config, dont forget to have space at the end of SC
SC="C:\\WINDOWS\\system32\\sc.exe ";
CONFIG="config";
//declare the Service (Myservice)
ServiceName = "Myservice";
ServiceDisplayName = "Myservice";
ServiceDescription = "This service is incharge for blablabla";
ServicePathFile = "c:\\Projects\\MMNew\\Shared\\Dll\\Myservice.exe";
StartService = TRUE;
StartServiceArgs = "";
//check if the service exists if not, install it
if (ServiceExistsService ( ServiceName )= FALSE)
then ServiceAddService ( ServiceName, ServiceDisplayName, ServiceDescription, ServicePathFile, StartService, StartServiceArgs );
MessageBox (ServiceName +" has been installed", INFORMATION);
else
MessageBox (ServiceName +" already installed", INFORMATION);
endif;
MsiGetProperty (hMSI, "USERNAME", MMusername, nSize);
MsiGetProperty (hMSI, "PASSWORD", MMpassword, nSize);
//config the service username and password
LaunchAppAndWait (SC,CONFIG+" "+ServiceName+" obj= "+MMusername+" password= "+MMpassword , WAIT);
//remove then service in case of uninstall
if MAINTENANCE then
ServiceRemoveService (ServiceName);
endif;
end;
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 20, 2008
11:45 AM
Was hMSI set to ISMSI_HANDLE?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Mar 20, 2008
01:02 PM
You might need to set the buffer-size variable to a value larger than the string length before each call to MsiGetProperty; please search the InstallShield help for "MsiGetProperty" to see some examples...
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)