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
- :
- One more question is this possible through InstallScript?
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
‎Nov 06, 2011
01:00 PM
Get Drive Letter from INSTALLDIR
Hello All,
I am using InstallShield 2010;
I am doing a project where I need to create a MS SQL database and want to create this in some other place rather than the default at which it creates, so I am doing this through scripting.
But the problem lies with the permission settings of Win 7 which is not allowing me to create it in any newly created folders of C: Drive or even inside program files folders. I tried many of the options advised here in the forum by the seniors but failed to make it work with my scenario and have been scratching my head 😞 to make it work.
Now I am creating a folder called Database which will be created on the installation drive (i.e if user installs application on c: then it will be created on c: and if its installed on 😧 it will be created on 😧 ) so in script i need to put this drive name while creating the script for database creation below is my script. It will be a great help if some one can guide me further to get this working.
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME = '[I-Don'tKnow-This-Drive]Database\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = '[I-Don'tKnow-This-Drive]Database\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
Thanks in Advance for your kind help;
Best Regards,
Sam
I am using InstallShield 2010;
I am doing a project where I need to create a MS SQL database and want to create this in some other place rather than the default at which it creates, so I am doing this through scripting.
But the problem lies with the permission settings of Win 7 which is not allowing me to create it in any newly created folders of C: Drive or even inside program files folders. I tried many of the options advised here in the forum by the seniors but failed to make it work with my scenario and have been scratching my head 😞 to make it work.
Now I am creating a folder called Database which will be created on the installation drive (i.e if user installs application on c: then it will be created on c: and if its installed on 😧 it will be created on 😧 ) so in script i need to put this drive name while creating the script for database creation below is my script. It will be a great help if some one can guide me further to get this working.
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME = '[I-Don'tKnow-This-Drive]Database\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = '[I-Don'tKnow-This-Drive]Database\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
Thanks in Advance for your kind help;
Best Regards,
Sam
(16) Replies
Not applicable
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 06, 2011
07:00 PM
You can try the function GetDisk.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 06, 2011
11:24 PM
Thanks Kevin for the help extended. I am sort of new to InstallShield some how I have reached this stage. Would you please tell me step wise what exactly needs to be done
Just to Add here I did go through a search on GetDisk in this forum but there is no clear enough step wise explanation to follow 😞
Thanking you in advance for your kind help,
Best Regards,
Sam
Just to Add here I did go through a search on GetDisk in this forum but there is no clear enough step wise explanation to follow 😞
Thanking you in advance for your kind help,
Best Regards,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 07, 2011
06:41 PM
You may want to mention the project type as well.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 08, 2011
01:22 AM
Thanks TsungH for the support extended, I am in Basic MSI Project Type; and would like to add that I had started the Project using the Visual Basic 6.00 Wizard.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 08, 2011
09:31 AM
Ok, here finally I was able to write a InstallScript to use GetDisk and run it 🙂 .
What I did was execute that and create a folder named myData on same drive as the InstallDir.
Now this is the 2nd function which I have written to get the Drive and pass that drive to SQL Database creation script (getDriveValue + \myData) eg., C:\myData
Then I execute it with custom Actions name getMeTheFolderPath
Now, how do I call this value into the SQL Database Creation Script is this correct? or am I doing something wrong here :confused:
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME ='%getMeTheFolderPath%\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = '%getMeTheFolderPath%\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
What I did was execute that and create a folder named myData on same drive as the InstallDir.
Now this is the 2nd function which I have written to get the Drive and pass that drive to SQL Database creation script (getDriveValue + \myData) eg., C:\myData
export prototype STRING get_FolderPath(hMSI)
function get_FolderPath(BYREF STRING)
STRING svDisk;
STRING svPath;
STRING svReturnPath,
begin
// Get the drive designation from the selected directory name.
if (GetDisk (INSTALLDIR, svDisk) < 0) then
// Report the error.
MessageBox ("GetDir failed.", SEVERE);
else
svPath= svDisk+"\\takhzeenDataDB";
if (ExistsDir (svPath) = EXISTS) then
//return the Folder Path
return svReturnPath;
endif;
endif;
end;
Then I execute it with custom Actions name getMeTheFolderPath
Now, how do I call this value into the SQL Database Creation Script is this correct? or am I doing something wrong here :confused:
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME ='%getMeTheFolderPath%\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = '%getMeTheFolderPath%\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 08, 2011
10:51 AM
Create a new msi property in Property Manager. Set the value using MSISetProperty().
E.g. Create msi property called 'MYCUSTOMPATH' in Behavior & Logic > Property Manager. In your get_FolderPath() you can simply set it by adding this line:
Now, in InstallShield IDE, go to Server Configuration > SQL Scripts. Right Click SQL Scripts in the middle panel and add a new SQL connection. Right click again and add your script either as a new script, or import existing file or insert it. Highlight the newly added script and on the right side go to Text Replacement tab. Click 'Add'. You can put your parameter name and the Msi Property name. The value of your MSI property will replace the parameter. This thread shows a screenshot.
E.g. Create msi property called 'MYCUSTOMPATH' in Behavior & Logic > Property Manager. In your get_FolderPath() you can simply set it by adding this line:
MsiSetProperty( ISMSI_HANDLE, "MYCUSTOMPATH", svPath);
Now, in InstallShield IDE, go to Server Configuration > SQL Scripts. Right Click SQL Scripts in the middle panel and add a new SQL connection. Right click again and add your script either as a new script, or import existing file or insert it. Highlight the newly added script and on the right side go to Text Replacement tab. Click 'Add'. You can put your parameter name and the Msi Property name. The value of your MSI property will replace the parameter. This thread shows a screenshot.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 08, 2011
02:17 PM
Dear skolte, thanks for your kind help, I followed your steps but was not able to get it right please check and help me know where I am getting it wrong :confused:
1. I created MSI Property getMeFolderPathHere = 0
2. Then I Set this Property in my Function as below
3. Then in Script I put the parameter as below
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME ='svPath\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = 'svPath\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
4. Then in Text Replacement
Find What = svPath
Replace With = [getMeFolderPathHere]
Thanks in advance,
Sam
1. I created MSI Property getMeFolderPathHere = 0
2. Then I Set this Property in my Function as below
export prototype STRING get_FolderPath(hMSI)
function get_FolderPath(BYREF STRING)
STRING svDisk;
STRING svPath;
STRING svReturnPath,
begin
// Get the drive designation from the selected directory name.
if (GetDisk (INSTALLDIR, svDisk) < 0) then
// Report the error.
MessageBox ("GetDir failed.", SEVERE);
else
svPath= svDisk+"\\myData";
if (ExistsDir (svPath) = EXISTS) then
//return the Folder Path
MsiSetProperty(ISMSI_HANDLE,"getMeFolderPathHere",svPath);
endif;
endif;
end;
3. Then in Script I put the parameter as below
[CODE]USE [master]
GO
CREATE DATABASE [dataDB] ON PRIMARY
( NAME = N'dataDB', FILENAME ='svPath\dataDB.mdf' , SIZE = 8384KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB )
LOG ON
( NAME = N'dataDB_log', FILENAME = 'svPath\dataDB.LDF' , SIZE = 7616KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)
GO[/CODE]
4. Then in Text Replacement
Find What = svPath
Replace With = [getMeFolderPathHere]
Thanks in advance,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 08, 2011
03:41 PM
I see a couple of problems with your code. I think custom property name needs to be all CAPS i.e. GETMEFOLDERPATHHERE.
Secondly, your method doesn't have return type 'STRING' in method definition. It should match the method declaration. Actually, I don't know why you need to return the STRING path once you have set the MSI Property.
BYREF STRING cannot be the argument to the method, instead it has to be a variable name.
Also, not sure where are you sequencing your Custom action, the name of the custom action needs to match the name of the method.
Note, turn on automatic msi logging, that helps a lot. It's in General Information > Create MSI Logs, set it to Yes. Once you do that, go to Media > Releases and select Release 1, go to Setup.exe tab and under MSI Comman-line arguments type
Then build and run your installer. Once installed, just go to Start > Run and type %appdata% and hit Enter. In the window that comes up (your local user directory), search for the log file, this is the log file for your entire install and will show you detailed steps. It makes it much easier to dig the problems.
By the end of the day today, if you want I will try to put together a quick sample for you to show how this can be done. Let me know if you need it.
Secondly, your method doesn't have return type 'STRING' in method definition. It should match the method declaration. Actually, I don't know why you need to return the STRING path once you have set the MSI Property.
BYREF STRING cannot be the argument to the method, instead it has to be a variable name.
Also, not sure where are you sequencing your Custom action, the name of the custom action needs to match the name of the method.
Note, turn on automatic msi logging, that helps a lot. It's in General Information > Create MSI Logs, set it to Yes. Once you do that, go to Media > Releases and select Release 1, go to Setup.exe tab and under MSI Comman-line arguments type
/L*v %appdata%\MyCustomLog.txt
Then build and run your installer. Once installed, just go to Start > Run and type %appdata% and hit Enter. In the window that comes up (your local user directory), search for the log file, this is the log file for your entire install and will show you detailed steps. It makes it much easier to dig the problems.
By the end of the day today, if you want I will try to put together a quick sample for you to show how this can be done. Let me know if you need it.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 09, 2011
01:39 AM
Thanks A Lot skolte, finally we made it work .. Thanks Again!!!!
This was not needed I removed it 😄
Did this but didn't help much in my case 😞
That was really kind of you, but I am using 2010 and I was not able to open it had to use editor to open the .rul file and get the function out from there; and it helped a lot to know what I was missing
(I am downloading a trial version 2012 now just to look at your file may be I can learn something new from it, thanks Again)
I followed these steps and corrected my Project
1. I think custom property name needs to be all CAPS i.e. GETMEFOLDERPATHHERE.
2. BYREF STRING cannot be the argument to the method, instead it has to be a variable name.
After doing all the said thing it was still not working .. you know what (i may sound idiot but may be being novice) I had created two different .rul files for two functions I merged them and it was all fine :cool:
Now, I have got what I needed; its working .. Really Appreciate your kind support thanks Again,
Best Regards,
Sam
Secondly, your method doesn't have return type 'STRING' in method definition. It should match the method declaration. Actually, I don't know why you need to return the STRING path once you have set the MSI Property.
This was not needed I removed it 😄
Note, turn on automatic msi logging, that helps a lot. It's in General Information > Create MSI Logs, set it to Yes. Once you do that, go to Media > Releases and select Release 1, go to Setup.exe tab and under MSI Comman-line arguments type
Did this but didn't help much in my case 😞
By the end of the day today, if you want I will try to put together a quick sample for you to show how this can be done. Let me know if you need it.
That was really kind of you, but I am using 2010 and I was not able to open it had to use editor to open the .rul file and get the function out from there; and it helped a lot to know what I was missing
(I am downloading a trial version 2012 now just to look at your file may be I can learn something new from it, thanks Again)
I followed these steps and corrected my Project
1. I think custom property name needs to be all CAPS i.e. GETMEFOLDERPATHHERE.
2. BYREF STRING cannot be the argument to the method, instead it has to be a variable name.
After doing all the said thing it was still not working .. you know what (i may sound idiot but may be being novice) I had created two different .rul files for two functions I merged them and it was all fine :cool:
Now, I have got what I needed; its working .. Really Appreciate your kind support thanks Again,
Best Regards,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 09, 2011
02:03 AM
skolte can this be done via InstallScript? or any other better method you may advice
What I want to do
I need to run two .exe files on command prompt with some parameters
On completion I need to delete that two files along with the Directory it was in (which I am creating just for this while in installation)
Thanks in Advance,
Sam
What I want to do
I need to run two .exe files on command prompt with some parameters
On completion I need to delete that two files along with the Directory it was in (which I am creating just for this while in installation)
Thanks in Advance,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 09, 2011
06:19 AM
Done !!! 😄
It was quite simple using Custom Actions .. Once Again thanks All for the kind support !!!
Best Regards,
Sam
It was quite simple using Custom Actions .. Once Again thanks All for the kind support !!!
Best Regards,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 09, 2011
10:29 AM
I am glad that everything works for you now. I am happy that I could be of help with my little knowledge. 🙂
The other question you asked, about running two exes and deleting files with the dir once finished, can easily be accomplished through InstallScript. Since you already have a custom action in place I won't go in details.
One thought from my experience is it is always better to put as much burden as possible on your InstallShield project to do stuff for you. Only when you are limited by InstallShield's abilities to carry out certain tasks (e.g. Database Structure Comparison) then only choose to go to Custom Actions.
Three reasons:
1. It is much easier to manage the Installer projects when everything is in one place.
2. Debugging, locating and fixing problems becomes much easier.
3. If a new person needs to be brought to team, chances of him/her knowing an invisible code in a custom action are less so he/she might end up breaking stuff.
Good luck.
The other question you asked, about running two exes and deleting files with the dir once finished, can easily be accomplished through InstallScript. Since you already have a custom action in place I won't go in details.
One thought from my experience is it is always better to put as much burden as possible on your InstallShield project to do stuff for you. Only when you are limited by InstallShield's abilities to carry out certain tasks (e.g. Database Structure Comparison) then only choose to go to Custom Actions.
Three reasons:
1. It is much easier to manage the Installer projects when everything is in one place.
2. Debugging, locating and fixing problems becomes much easier.
3. If a new person needs to be brought to team, chances of him/her knowing an invisible code in a custom action are less so he/she might end up breaking stuff.
Good luck.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 09, 2011
10:49 AM
🙂 skolte, slowly I am getting to know (ofcourse due to your guidance) that InstallScript really opens up so many windows to have control over your Installation, before I was feeling handicapped now I feel I am a master too 😉
If you can get some time can u just brief me how do we do that with InstallScript (the question I asked of running .exe's)
Best Regards,
Sam
If you can get some time can u just brief me how do we do that with InstallScript (the question I asked of running .exe's)
Best Regards,
Sam
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 10, 2011
02:01 AM
- Add ".exe" files to Support Files
- Call these exe to installscript code, please refer following example
- Support files are automatically deleted after the installation is finished
Ex:
svExeFile = SUPPORTDIR ^ "Sample.exe";
LongPathToQuote(svExeFile, TRUE);
nOptions = LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN;
svCmdLine = " Parameter";
LaunchAppAndWait(svExeFile , svCmdLine, nOptions );
for more information please refer Installscript help LaunchAppAndWait function.
- Call these exe to installscript code, please refer following example
- Support files are automatically deleted after the installation is finished
Ex:
svExeFile = SUPPORTDIR ^ "Sample.exe";
LongPathToQuote(svExeFile, TRUE);
nOptions = LAAW_OPTION_WAIT | LAAW_OPTION_HIDDEN;
svCmdLine = " Parameter";
LaunchAppAndWait(svExeFile , svCmdLine, nOptions );
for more information please refer Installscript help LaunchAppAndWait function.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 10, 2011
02:21 AM
thanks palanisamy,
That looks quite comfortable 🙂 will look into it
Best Regards,
Sam
That looks quite comfortable 🙂 will look into it
Best Regards,
Sam