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: Need to read Env. Variable and rename a file accordingly
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 13, 2006
11:55 AM
Need to read Env. Variable and rename a file accordingly
I need to be able to read in the environment variables in my Windows install and depending on the value of one of the variables, which is a version of the software for that variable. Once I have the value which is either 12 or 15, I need to rename one of my exes to xxxxx15.exe and xxxxx12.exe to just xxxxx.exe according to the value returned. I see in the API that there is a getVariable method however I don't see that it returns the value for the variable. Has anyone else done this before?
(6) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 13, 2006
12:31 PM
You might see if $E(VARIABLE_NAME) works for you; in code, you can wrap that in resolveString...
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 14, 2006
08:07 AM
Will that return the value of the Env. variable though? The value is what I really need. I also thought about looking at the registry entries but I have not found anything that returns the value in the key either.
Maybe I am misreading the documentation. Any other suggestions?
Maybe I am misreading the documentation. Any other suggestions?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Nov 14, 2006
08:23 AM
Yes, for example try putting $E(USERNAME) on a dialog box and verifying that the value is returned.
The System Utility Service also provides methods for programmatically reading the values of environment variables, if you prefer to create a custom bean.
The System Utility Service also provides methods for programmatically reading the values of environment variables, if you prefer to create a custom bean.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 23, 2007
01:52 PM
I'm still having some problems with env variables, I'm hoping someone can help me. Does my build system need to have the env. variable that I am searching for in my installer? This doesn't make sense to me but thought I would ask.
I'm pulling in a Sybase variable from the system that the installer is going to be run from.
String ocs = arg0.resolveString( "$E(SYBASE_OCS)" );
ocs returns with the correct value, OCS-15_0 or whatever version it happens to be. From here I am trying to rename a dll accordingly and that is where I am having problems. No file ever gets renamed, all I get is the message that no DLL was renamed.This custom event is the last thing to run in the installer so I don't think that is an issue. Is there something wrong with my code?
I'm pulling in a Sybase variable from the system that the installer is going to be run from.
String ocs = arg0.resolveString( "$E(SYBASE_OCS)" );
ocs returns with the correct value, OCS-15_0 or whatever version it happens to be. From here I am trying to rename a dll accordingly and that is where I am having problems. No file ever gets renamed, all I get is the message that no DLL was renamed.This custom event is the last thing to run in the installer so I don't think that is an issue. Is there something wrong with my code?
String fifteen = "OCS-15_0";
String twelve = "OCS-12_5";
String instLoc = arg0.resolveString( "$P( absoluteInstallLocation )" );
FileService fileCop = ( FileService )arg0.getService( FileService.NAME );
if ( ocs == fifteen ) {
fileCop.copyFile( instLoc + "//bin//lib.dll.sybase15", instLoc + "//libDMdb_nt.dll", true);
JOptionPane.showMessageDialog( null, "Your sybase15 dll was renamed" );
}else if ( ocs == twelve ) {
fileCop.copyFile( instLoc + "//bin//lib.dll.sybase12", instLoc + "//libDMdb_nt.dll", true );
JOptionPane.showMessageDialog( null, "Your sybase12 dll was renamed " );
} else {
JOptionPane.showMessageDialog( null, "No dll was renamed" );
}
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 23, 2007
04:15 PM
When comparing two Java String quantities, perhaps try String.equals (or String.equalsIgnoreCase or String.compareTo) instead of ==?
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎May 24, 2007
10:31 AM
Thanks Robert, I happened to notice my programming error this morning.
![](/skins/images/A5EADE085F77DE82FB3B14D6B307AE6A/responsive_peak/images/icon_anonymous_message.png)