Creating BATCH file with InstallShield Professiona
Posted 16 January 2004 - 21:12
we are using installshield Professional 6.0 to package our application for distribution and while installing we need to create a batch file that contains certain information about the local 'System'.
I would like to know if this could be done with installshield and an example would be greatly appreciated.
Thanks in advance,
Posted 17 January 2004 - 01:11
What kind of local 'System' information are you looking for though, so I can put together an example? Let me know.
Edited by Taco Bell, 17 January 2004 - 01:12.
Posted 17 January 2004 - 01:26
My batch file should contain these:
java -jar myjarfile.jar
I sincerely appreciate it.
Posted 19 January 2004 - 14:15
Java installs a java.exe and javaw.exe into the WINSYSDIR, which should be in the path.
So if you run "java -jar myjarfile.jar", WINSYSDIR ^ java.exe is started, asks the registry, if it is the installed version, gets the path to the installed JRE and runs that java.exe (I suppose that is the way it goes ...)
You can add the java directory to the path, but (like you did in the example) make sure, it is before other JREs that may be in the path as well ... but that may disturb third party software, that have their jre 1.1.x in the path!
just my 0.02 € ...
Posted 20 January 2004 - 17:55
did you get a chance to look at my reply.
Posted 21 January 2004 - 01:46
In that case, I'll work on it tomorrow.
Posted 21 January 2004 - 01:57
Moreover, Perotin overlooked my concern that the users could have more than one JRE installed.
Posted 22 January 2004 - 15:49
However, I have it now and I've confirmed it works, so here you go.
|#define JRE_REG_KEY "SOFTWARE\\JavaSoft\\Java Runtime Environment\\1.4.1" |
#define JRE_REG_VALUE "JavaHome"
#define JRE_DISPLAY_NAME "Java Runtime Environment v1.4.1"
STRING szMsg, szBatchFilename, szKey, svValue, szName, szJavaDir;
NUMBER nResult, nResult1, nResult2, nvType, nvSize, nvFileHandle;
// HARD-CODED VALUES FOR THE EXAMPLE
TARGETDIR = "C:\\Program Files\\TargetFolder";
szBatchFilename = "javapath.bat";
// LOCATE THE JRE
szKey = JRE_REG_KEY;
szName = JRE_REG_VALUE;
nvType = REGDB_STRING;
nResult1 = RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize);
nResult2 = ExistsDir(svValue);
if (nResult1 = 0 && nResult2 = 0) then
szJavaDir = svValue;
// CREATE THE BATCH FILE FOR THE JRE
nResult1 = OpenFileMode(FILE_MODE_APPEND);
nResult2 = CreateFile(nvFileHandle, TARGETDIR, szBatchFilename);
if (nResult1 = 0 && nResult2 = 0) then
nResult1 = WriteLine(nvFileHandle, "set path=\""+szJavaDir+"\";%PATH%");
nResult2 = WriteLine(nvFileHandle, "java -jar myjarfile.jar");
if (nResult1 < 0 || nResult2 < 0) then
MessageBox("WARNING: Unable to write to the file '"+TARGETDIR^szBatchFilename+"'.", WARNING);
MessageBox("WARNING: Unable to create the file '"+TARGETDIR^szBatchFilename+"'.", WARNING);
MessageBox("WARNING: Unable to locate the "+JRE_DISPLAY_NAME+".", WARNING);
There are few things I should point out though.
The first is a minor thing. That being I replaced the tabs with 2 spaces to preserve the formatting of the post, but an original copy of the code is attached to this reply.
The second thing is that I have this code in an old-school program block to speed up its development & testing, but you can just rip that out and/or throw it in your own function call.
The third & final thing is a limitation of CreateFile and for that I'll simply quote the help:
|The CreateFile function's actions are not logged for uninstallation when logging is enabled. If you want a file that's created by CreateFile to be logged for uninstallation, transfer a starter file with the filename you want to the target system using XCopyFile while logging is enabled. You enable and disable logging with the Enable and Disable functions. XCopyFile actions are logged when logging is enabled, so the starter file will be logged for uninstallation. After transferring the logged starter file, you can write to or overwrite the logged starter file using CreateFile and other file-related functions. The filename must remain unchanged or it won't be found during uninstallation.|
So pretty easy to workaround. Just add a template batch file to one of your file groups then to cover the uninstall support.
Edited by Taco Bell, 22 January 2004 - 15:49.
Posted 12 February 2004 - 23:24
thanks so much for that.
We did not get a chance to work on that part of the installation yet. Will let you know how it went then.