5151 ParamExpanded: string;
5252begin
5353 ParamExpanded := ExpandConstant(Param);
54+ // Normalize: remove trailing backslash
55+ if (Length(ParamExpanded) > 0 ) and (ParamExpanded[Length(ParamExpanded)] = ' \' ) then
56+ ParamExpanded := Copy(ParamExpanded, 1 , Length(ParamExpanded) - 1 );
57+
5458 if not RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, ' Path' , OrigPath) then
5559 begin
5660 Result := True;
@@ -114,6 +118,10 @@ begin
114118 if CurUninstallStep = usPostUninstall then
115119 begin
116120 AppPath := ExpandConstant(' {app}' );
121+ // Normalize: remove trailing backslash
122+ if (Length(AppPath) > 0 ) and (AppPath[Length(AppPath)] = ' \' ) then
123+ AppPath := Copy(AppPath, 1 , Length(AppPath) - 1 );
124+
117125 if RegQueryStringValue(HKEY_CURRENT_USER, EnvironmentKey, ' Path' , OrigPath) then
118126 begin
119127 PathList := TStringList.Create;
@@ -136,7 +144,7 @@ begin
136144 end ;
137145
138146 // Normalize by removing trailing backslash for comparison
139- if PathItem[Length(PathItem)] = ' \' then
147+ if (Length( PathItem) > 0 ) and (PathItem [Length(PathItem)] = ' \' ) then
140148 PathItem := Copy(PathItem, 1 , Length(PathItem) - 1 );
141149
142150 if Uppercase(PathItem) = Uppercase(AppPath) then
0 commit comments