Summary
This article provides sample code demonstrating how to convert Windows long paths from the Choose Install Folder Panel and the Choose Folder Panel to a Windows short path.Synopsis
This article provides sample code demonstrating how to convert Windows long paths from the Choose Install Folder Panel and the Choose Folder Panel to a Windows short path. First, private String variables are declared to store the long paths and the short paths after the conversions. Then, the two long path class variables are initialized to the values of the InstallAnywhere variables containing the paths from the Choose Install Folder Panel and the Choose Folder panel using the substitute method of the InstallerProxy object to resolve each InstallAnywhere variable. After getting a handle on the Win32Service, thegetShortPath method is called by passing in the string variable containing the long path as a parameter. Lastly, the class prints to the console the values of the long paths and the short paths after the conversion.
-
The sample code below does not perform error checking beyond printing the stack trace. Also, the sample code below requires that all of the directories in the long path exist before being converted into a short path.
-
Because the code uses the Win32Service, project option Project > JVM Settings > Add service support for custom code must be selected.
Discussion
import com.installshield.wizard.platform.win32.Win32Service;
import com.zerog.ia.api.pub.*;
import java.net.*;
import java.io.*;
public class ConvertLongPathToShortPathAction extends CustomCodeAction
{
private String longPath1;
private String longPath2;
private String shortPath1;
private String shortPath2;
public void install( InstallerProxy ip ) throws InstallException
{
longPath1 = ip.substitute( "$USER_INSTALL_DIR$" );
longPath2 = ip.substitute( "$USER_SELECTED_FOLDER$" );
try
{
Win32Service ws = (Win32Service) ip.getService(Win32Service.class);
shortPath1 = ws.getShortPath(longPath1);
shortPath2 = ws.getShortPath(longPath2);
}
catch (Exception e)
{
e.printStackTrace();
}
System.out.println("longPath1 = "+longPath1);
System.out.println("longPath2 = "+longPath2);
System.out.println("shortPath1 = "+shortPath1);
System.out.println("shortPath2 = "+shortPath2);
}
}Additional Information
Related Articles
Exclude the recycling bin from file evidence scanning 27Number of Views FlexNet inventory agent may not return any Oracle inventory on Windows if the %TEMP% environment variable resolves to a pa… 4Number of Views ndtrack process may crash after logging "IBM Db2 tracking finished" message when the Java audit option is enabled and a ja… 4Number of Views Condition on Checking Windows Registry in the Case of a Variable Windows Registry Path 5Number of Views Unable to See or Access Mapped Path During Installation 14Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago