TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Silent Batch File Usage (Hide DOS Window)

Hi there,

I know this topic has come up several times in the past but I haven't managed to find an answer that I think is suitable for my project.
There are files installed on the target computer that need to store values entered during install time. i.e. the installer accepts a directory path and outputs this to the rewritten file.
The method of rewriting the file is through a java class, but in order to launch that java class, I'm using a batch file to call "java [className] [commandLineParameters]".
And so, to call the batch file I use "Exe with Working Dir..." I call my batch file with the params needed in the java file. ([#FileRewrite.bat] etc).

Anyway, I have switched echo off in the batch file and called "javaw" instead of java, but I still get an empty DOS window popping up...I've tried using <viewer.exe> but the problem remains, and I don't want to use VBS due to it's restrictions on using parameters (I repeat the rewrite operation around 10/15 times with varying parameters each time).

What else can I do to prevent these popups? Or am I going to be falling back to writing a new DLL or EXE to perform this operation?

Thanks,

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

Hi,

This can be done by using a VBScript or JScript custom action which calls the BAT file with the command window hidden. There is a sample VBScript on the forum, please take a look:
http://www.advancedinstaller.com/forums ... and+window
I don't want to use VBS due to it's restrictions on using parameters
Note that you can pass parameters to a VBScript custom action by using public properties. These properties can be set in the "Install Parameters" page and accessed in the custom action by using the Session.Property object.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Well...still I'm reluctant to use VBS because:
I have 13 calls to rewrites
Each rewrite accepts 4 or 5 parameters
These are rarely the same, i.e. "input file" "output file" "tag to replace" "replacement tag".

So, if I wanted to do this as described, I would need to set all 4 properties (4 custom actions to set the property) and then call the rewrite.
5 actions * 13 rewrites, this is very messy!

Could you suggest an alternative? Maybe it will be necessary to use an exe for this process instead.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

The alternative is to use an EXE which handles the rewrites. In this EXE you can use the ShellExecute function:
http://msdn2.microsoft.com/en-us/library/bb762153.aspx

or the CreateProcess function:
http://msdn2.microsoft.com/en-us/library/ms682425.aspx
http://msdn2.microsoft.com/en-us/librar ... S.85).aspx

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Well, I already had a java application to rewrite the file and I found out how to create an executable jar. Now I call this as an "File attached to Installation"...it works on one platform (i.e. it rewrites with no label), but when I run it on another (with WinRar installed) it opens the jar file with WinRar!! How do I solve this problem?!
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Hi,

This happens because on the machine with the problem the JAR extension is associated with WinRar.

Here are the steps to do what you need:
- add the JAR as a temporary file in the "Files and Folders" page
- go to the "Custom Actions" page and create a new Attached custom action
- in the "Select a file to execute as a custom action" dialog browse to the Advanced Installer installation folder (usually it's "C:\Program Files\Caphyon\Advanced Installer 6.1.1\") and go to the "custact" subfolder
- select the "aicustact.dll" file and add it as a custom action
- in the "Function Name" combo choose the CreateEXEProcess function
- set the "Action Data" field to the command line which runs the JAR, for example:

Code: Select all

java -jar "[&test.jar]"
- the quotation marks are used to make sure that Windows Installer recognizes the path of the JAR even if it contains spaces

Since the JAR is a temporary file, it can be launched only after the "CostFinalize" standard action. Also, it will be automatically removed when the installation is finished. Let me know if you encounter any problems.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
TomGarrett
Posts: 25
Joined: Fri Nov 16, 2007 12:44 pm

Excellent, just what I needed.
Thank you very much!

Return to “Common Problems”