Archive: Path Manipulation - square box character?


Path Manipulation - square box character?
This is in reference to the path manipulation functions here:
http://nsis.sourceforge.net/archive...e.php?pageid=91

I am using the path manipulation functions mentioned above. On Win9x based machines the functions add a path to the end of autoexec.bat (SET PATH=%PATH%;mydir). But on some machines there is a weird square character just above the SET PATH line. I am not positive what this square character is, but SET PATH never gets executed. Any ideas?


Try that link again...

http://nsis.sourceforge.net/archive/....php?pageid=91


Does that square character appear after the line too? Can you please attach the autoexec.bat file? What version of Windows have you tested it on?


The square character does not occur after the line, only just before it. This occurred on several Windows 98 machines. I have tested on all versions of Windows. It seems to only occur on some Windows 98 machines.

My guess is that the square box character is an end of file character or a non-printable character. My gut feeling is that some autoexec.bat files have this character and some don't. That would explain why it only occurs on some Windows 98 boxes, not all.

I fixed the machine here in the office that had this problem already, so I no longer have an autoexec.bat to send you. If another user reports the problem (one called last week but I told him how to fix), I will get them to email it to me and I will post it here.


Here is an example autoexec.bat file.


As you suspected, in the cases where things go wrong there is an end-of-file character at the end of the file to which you are adding the path. In your ZIP file, the first line ends with ASCII codes 13, 10, 26 (the normal sequence at the end of a line is ASCII 13, 10).

One solution would be check that the file does not end with ASCII code 26 before you append the new data.

The thread at http://forums.winamp.com/showthread.php?threadid=130099 may give you some ideas of how to go about this.


Yey for DOS :(

On my todo.


I wrote a Delphi dll that can add a path to any 95 or NT based platform.

It handles the square box character problem described above by searching for the ASCII character #26 on a line by itself and deleting that line if found.

It also checks to see if the path you are adding is already in the system path. If it is, then it doesn't add it. This could save the user a reboot on 95 platforms. For NT based platforms, it automatically calls SendMessage - you don't have to call that in your install script.

For 95 based platforms, autoexec.bat gets modified. For NT platforms, the Path data in the key HKLM\System\CurrentControlSet\Control\Session Manager\Environment\ gets modified.

To add a path:

Path::AddToPath $INSTDIR
Pop $0 ;<--- will be either "Reboot" or "NoReboot"


To remove a path:
Path::RemoveFromPath $INSTDIR
Pop $0 ;<--- will be either "Reboot" or "NoReboot"


The path must exist prior to a call to AddToPath or RemoveFromPath (GetShortPathName doesn't work right unless the Path exists).

After this lengthy post the forum won't allow me to post the zip file because it's too big! Well, if someone wants it I can email it to you.

Please create an archive page for your plug-in and mail the plug-in to one of the admins.


Err, what's an archive page?


http://nsis.sourceforge.net/archive


Finally fixed.