Sorry, I think I overlooked the actual source of the quotes. Since this is my first effort with SetupBuilder (still evaluating actually), I'm apparently unable to use the Detect Previous Version function (given that the application, if already installed, was installed by some other installer.) So instead, I've identified a Registry item that allows me to locate the current installation. That string is a complete filespec to the main executable, which just happens to be enclosed in quotes (e.g. "c:\program files\company\product\bin\file.exe"). So my goal is to split off the \bin\file.exe and set the result to %_SB_INSTALLDIR%, so that the update operation can proceed without needing the user to verify the location where it was previously installed.

My script code looks something like this:

Set Variable %OLDPATH% to FUNCTION:Get Registry ...

At this point, %OLDPATH% contains "c:\program files\company\prod\bin\file.exe" (including quotes)
Now use Split Source function to split off the last two segments of the path in order to get to the desired install directory...

If %_SB_ERRORCODE% Not Equals "0" Then
Set Variable %OLDPATH% and %OLDFILE% to FUNCTION:Split Source String at Last Occurrence of Search String(%OLDPATH%, "\")
Set Variable %_SB_INSTALLDIR% and %BINDIR% to FUNCTION:Split Source String at Last Occurrence of Search String(%OLDPATH%, "\")


Now %_SB_INSTALLDIR% contains "c:\program files\company\prod (no trailing quote). Because I am unsure of whether the Registry string contains quotes, I now need to detect the presence of the leading quote and either remove it or add one to the end. It seems that removing the leading quote is the best way to go, since %_SB_INSTALLDIR% seems to work better without explicitly quoted paths. So here's what I did, although it seems pretty cumbersome...

Set Variable %QUOTE% to FUNCTION:Left(%_SB+_INSTALLDIR%,1)
If %QUOTE% Equals """ Then
Set Variable %PATHLEN% to FUNCTION:Len(%_SB_INSTALLDIR%)
Set Variable %_SB_INSTALLDIR% to FUNCTION:Mid(%_SB_INSTALLDIR%, %PATHLEN%, 2)
End


By trial and error I figured out that I could use three double-quotes (""") to check if %QUOTE% equaled one, i.e. ASCII 42. And I'm not sure whether the Mid function supports a special value for the length, indicating from the start point to the end of the string.

I guess what I'm looking for is the definitive syntax for referencing special characters like quotes and spaces, and clarification on whether they are treated specially for the purposes of string operations such as comparisons, appends, InStr, etc. Related to that, any other guidance on best practices or functions for manipulating path strings would be helpful.