jabelsc
Posts: 12
Joined: Tue Sep 05, 2006 10:12 am

Customs actions with .vbs files

Hello everybody!!

I've installed several prerequisites (like Oracle XE) and after that some files were copied to the target computer. I want to execute a .vbs file that runs in a minimized window a .bat file which is in charge of creating a new Oracle user and importing its schema. I want to do this just after installing everything and wait for it to be run until finish the installation.

I've tried to create a Custom Action (InstallExecuteSequence/Commit/ Synchronous execution, ignore return cod/Commit) indicating Visual basic script in the field Source Type and the source paht of the .vbs file which contains the following code:

CreateObject ("Wscript.Shell").Run "CreateSchema.bat",2

where CreateSchema.bat is working correctly if running under a command window. But the .vbs doesn't work.

I've also tried to create as an script inline filling in the field Script Text with the instruction above but nothing again.

Another point is that I want to show a dialog with a customized warning text before installing the prerequisites. Is it possible to do that?

Can anybody help me, please?

THanks a lot.

Abel S.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

You don't need to call the .bat throw the .vbs file. Call directly the .bat file like this:

Add the .bat file to the "Files and Folders" view and execute it as custom action. Go to "Custom Actions" page and add a "New Installed Custom Action" under commit section, browse for the .bat file. Use (NOT Installed) as "Execution Condition" for the custom action.
Another point is that I want to show a dialog with a customized warning text before installing the prerequisites. Is it possible to do that?
This can not be done, but please tell me why you need that?

Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
jabelsc
Posts: 12
Joined: Tue Sep 05, 2006 10:12 am

Hello Gheorghe!

Thanks for your answer.

I've done the way you've said, calling directly the .bat file, but I want to run it minimize and I cannot do it in any other way (I call sqlplus and the Oracle imp utilities in the file).

I want to show a dialog before installing the prerequisites to warn the user that the installation process will take a long, because the whole program installation takes about 20 minutes.

Thanks again.

BR.

Abel S.
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

The problem is that the .vbs file is not correct. To run a .bat file with cmd window hidden please use following script:

Code: Select all

const WindowStyleStealth  = &H20000000
set WSO = createobject("WScript.Shell")
WSO.run "%comspec% /c CreateSchema.bat", WindowStyleStealth, false 
Note that you need to add those files in the "Files and Folders" view in the same folder. To launch the .vbs file switch to "Custom Actions" page and "Add Predefined Custom Action->Launch File or Open URL" under the "Commit" section. After you browse for the .vbs file in the "Command Line" field enclose the text in quotes (like this "[#test.vbs]").

Hope this helps.

Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
jabelsc
Posts: 12
Joined: Tue Sep 05, 2006 10:12 am

Thanks a lot Gheorghe!

BR.

Abel S.
Phobos
Posts: 85
Joined: Fri Sep 08, 2006 11:52 am
Location: Germany

Hi Gigi,

I tested this script and it works, but if I use it to run my custom action .cmd files the installer does not wait for the .cmd file to complete.

My .cmd file contains several commandlines and takes a few minutes to finish. When I use the .cmd as custom action it gets started, executes all the commandlines, and once it has finished the installer continues. But when I use the .vbs file the installer executes it, but does not wait for the .cmd to complete.
Any idea? Thanks!
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,
I tested this script and it works, but if I use it to run my custom action .cmd files the installer does not wait for the .cmd file to complete.
To wait for the .cmd to finish use true for the third parameter of the run function.

Code: Select all

WSO.run "%comspec% /c CreateSchema.bat", WindowStyleStealth, true
Best Regards,
Gigi
_______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
dbalsbaugh
Posts: 27
Joined: Mon Dec 11, 2006 10:41 pm

Is there anyway to accomplish this using the VBScript Inline feature? I can't seem to figure out how to enter multiple lines. It would just be nice to not have to include a bunch of .vbs files when installing.
Phobos
Posts: 85
Joined: Fri Sep 08, 2006 11:52 am
Location: Germany

Hi,

you should be able to get the script into one line doing it like this:

Code: Select all

const WindowStyleStealth  = &H20000000 : set WSO = createobject("WScript.Shell") : WSO.run "%comspec% /c CreateSchema.bat", WindowStyleStealth, false
So just use the : to seperate the lines. The script will work fine like this, but I havn't tested this with the VBScript Inline feature.
Last edited by Phobos on Fri Jan 19, 2007 11:49 am, edited 1 time in total.
dbalsbaugh
Posts: 27
Joined: Mon Dec 11, 2006 10:41 pm

Yes, that worked. Thanks for the tip.
vakbijevs
Posts: 12
Joined: Wed Nov 15, 2006 3:43 pm

gigi wrote:Hi,
Another point is that I want to show a dialog with a customized warning text before installing the prerequisites. Is it possible to do that?
This can not be done, but please tell me why you need that?

Regards,
Gigi
Gigi,

It is possible to run an VBS script "prerequisites" (java version check, inside in MSI file, we can't use .exe in project) and if java version is < 1.4 then show CustomDialog with some text and quit from installation?

Code: Select all

On Error Resume Next
Set WshShell = Wscript.CreateObject("Wscript.Shell")
strJavaSetting = WshShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\CurrentVersion")
IF strJavaSetting > "1.4" Then
WScript.Quit (0)
ELSE

<????>

END IF
gigi
Posts: 2103
Joined: Tue Apr 11, 2006 9:55 am
Contact: Website

Hi,

I don't understand for what you need to do that. Please give me more details.

However to quit the installation if a condition is not meet you can use a "Launch Condition":
http://www.advancedinstaller.com/user-g ... tions.html

Best Regards,
Gigi
______________
Gheorghe Rada
Advanced Installer Team
http://www.advancedinstaller.com
Phobos
Posts: 85
Joined: Fri Sep 08, 2006 11:52 am
Location: Germany

Hi,

I use the script provided by gigi to hide my .cmd custom actions. This is working fine so far, I used it in several projects already. However, now one of my customers experienced the issue that the script was not executed, but opened with Microsoft Visual Studio.
This, of course, prevented my application from working, as the required .cmd files did not get executed during installation.

This is the first time this happened, is there any way to prevent this from happening again? Can I execute .cmd files hidden without using a vbs file?

Thanks.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,
However, now one of my customers experienced the issue that the script was not executed, but opened with Microsoft Visual Studio.
I'm not sure why this happens, perhaps you are using "viewer.exe" to run the custom action. Note that this custom action should be used as an Attached custom action.
Can I execute .cmd files hidden without using a vbs file?
Note that you can use an EXE or C++ DLL custom action instead of the VBScript.

We have an example for a DLL custom action, please take a look:
http://www.advancedinstaller.com/user-g ... n-dll.html
You can modify this example to create your own DLL custom action.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Phobos
Posts: 85
Joined: Fri Sep 08, 2006 11:52 am
Location: Germany

Hi cosmin,

Yes, you are right, I use viewer.exe to run the custom action. I followed gigi's explanation:
Note that you need to add those files in the "Files and Folders" view in the same folder. To launch the .vbs file switch to "Custom Actions" page and "Add Predefined Custom Action->Launch File or Open URL" under the "Commit" section. After you browse for the .vbs file in the "Command Line" field enclose the text in quotes (like this "[#test.vbs]").
Doing this always leads to viewer.exe executing the .vbs file. If I add the script as an attached custom action, It won't work anymore. I already tried modifying the script, but without success.

How do I have to modify the script so it works as attached custom action?

Return to “Common Problems”