If there is a better way to do this, I don't know it and this method seems to work nicely for me.
I Hope this helps.
1. Create a new property called "IsReadOnlyPath" and set it to True. Create a new property called "TMP_INSTALLDIR" and set it to [INSTALLDIR]
2. Create a custom action in JScript or VBScript to check if the path is read only. For this sample we can call it "CheckReadOnlyPath" which will set the "IsReadOnlyPath" property created in step 1.
In addition to this, it will set INSTALLDIR from TMP_INSTALLDIR only if the path is writable.
3. Edit the "ChangeFolder/SpawnDialog" PushButton event for the Destination Folder dialog from INSTALLDIR to TMP_INSTALLDIR
3. Edit the "Next" PushButton events for the Destination Folder dialog to the following (in this order)
using the form:Event,Argument,Condition
---------------------------------------------
DoAction, CheckReadOnlyPath, 1
[ErrorDialog_Text],The path sucks!,IsReadOnlyPath="True"
SpawnDialog,ErrorDialog,IsReadOnlyPath="True"
NewDialog,ReadyToInstall,IsReadOnlyPath="False"
This should do the trick for you.
PS: Here is a little JScript sample to get you started on the custom action.
Code Sample |
//------------------------------------------------------- // function: CheckReadOnlyPath() //------------------------------------------------------- function CheckReadOnlyPath() { var oFSO = new ActiveXObject( "Scripting.FileSystemObject" ); var sPath = Session.Property( "TMP_INSTALLDIR" );
//make sure no final backslash on TMP_INSTALLDIR path var oRe = /\\$/g; sPath = sPath.replace(oRe, "") );
//First blindly delete any pre-existing folder by that name. //don't care about errors on this first call try { oFSO.DeleteFolder( sPath + "\\" + "Check" ); } catch( e ) { }
try { oFSO.CreateFolder( sPath + "\\" + "Check" ); oFSO.DeleteFolder( sPath + "\\" + "Check" ); Session.Property( "IsReadOnlyPath" ) = "False" Session.Property( "INSTALLDIR" ) = Session.Property( "TMP_INSTALLDIR" ) } catch( e ) { Session.Property( "IsReadOnlyPath" ) = "True" } oFSO = null; }
|