cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Techie42
Level 6

LongPathToShortPath in Java?

Is there a IS11.5 Multiplatform LongPathToShortPath() function?

Thanks,

Bradley
Labels (1)
0 Kudos
(8) Replies
RobertDickau
Flexera Alumni

It's not an obvious place for it, but the Win32Service interface has a getShortPath method that might do what you want.
0 Kudos
Techie42
Level 6

RobertDickau wrote:
It's not an obvious place for it, but the Win32Service interface has a getShortPath method that might do what you want.


Okay I see the method:
public java.lang.String getShortPath(java.lang.String longPath)
throws com.installshield.wizard.service.ServiceException

I would guess that I would use this in a custom Wizard bean to take the install path and update a property with the short name. I could then use that property to do an ascii update on the files i have to modify.

You wouldn't happen to have a code snip handy showing getshortpath in use would you?

Thanks in anycase,

Bradley
0 Kudos
RobertDickau
Flexera Alumni

Here's a dusty old wizard action I had lying around; might still work...
import com.installshield.util.*;
import com.installshield.wizard.*;
import com.installshield.wizard.platform.win32.*;
import com.installshield.wizard.service.*;

public class LongPathToShort extends WizardAction
{
private String longPath = "";
// hidden property where value is stored
private String value = "";
public void execute(WizardBeanEvent event)
{
longPath = resolveString(longPath);
try
{
Win32Service ws =
(Win32Service)getService(Win32Service.NAME);
value = ws.getShortPath(longPath);
}
catch (ServiceException se)
{
logEvent(this, Log.ERROR, se);
}
}
public String getLongPath( )
{
return longPath;
}
public void setLongPath(String longPath)
{
this.longPath = longPath;
}
}
0 Kudos
Techie42
Level 6

RobertDickau wrote:
Here's a dusty old wizard action I had lying around; might still work...


Nice.

So when compile and register this wizard action I add this to my project after the insrtall dir is set. I then pass the long path to the Wizard Action and it modifys the long path to short path and stores it in the string value.

Can I then pass this value as a Java property [$J(ShortPathString) ] back to my installer (to be used later in an ascii file update) by using this code...

...
System.setProperty("ShortPathString", value);
...

public String getShortPathString ()
{
return this.ShortPathString;
}

public void setShortPathString (String ShortPathString)
{
this.ShortPathString = ShortPathString;
}
....
0 Kudos
RobertDickau
Flexera Alumni

You shouldn't even need to set the Java system property; if you've left it as a wizard action (if I remember correctly), $W(beanid.value) should contain the short string...

But yes, if that doesn't work, your System.setProperty ==> $J(something) trick should work.
0 Kudos
Techie42
Level 6

RobertDickau wrote:
You shouldn't even need to set the Java system property; if you've left it as a wizard action (if I remember correctly), $W(beanid.value) should contain the short string...

But yes, if that doesn't work, your System.setProperty ==> $J(something) trick should work.


Oh. So $W(beanid.valuse) would be the bean id of the wizard action then?

Thanks I will give it a try,

Bradley
0 Kudos
Techie42
Level 6

RobertDickau wrote:
You shouldn't even need to set the Java system property; if you've left it as a wizard action (if I remember correctly), $W(beanid.value) should contain the short string...

But yes, if that doesn't work, your System.setProperty ==> $J(something) trick should work.


When I used $W(bean.value) ( the actual BeanID=bean) the return value is null and when I used $J(ShortPathString) the value was left out completely (very null.)

Any thoughts?

Bradley
0 Kudos
RobertDickau
Flexera Alumni

For testing, what if you display the value of the short path using a message dialog (that is, something like javax.swing.JOptionPane)? That will help determine if it's a problem with the service or with your custom bean...
0 Kudos