Archive: Long file names problem


Long file names problem
Here is a serious problem that I don't think has been resolved. The only information I could find in the forums about it was here, unfortunately no one responded.

The problem is long file names (greater than 8 characters, like bigfilename.txt) get renamed incorrectly on reboot (to bigfil~1.txt for example). This occurred on a Win98 machine here at the office, but it could happen on other operating systems as well (I haven't tried).

Anyone have any ideas on this problem?


The problem is that Win98 is DOS-based, so it renames before Windows starts. This is a Windows limitation.


Any workaround other than renaming all installation files to <= 8 characters?


Wininit.ini does not support long file names. Files installed using this method should have 8.3 file names.


You could try using "RunOnce" section of the registry to rename files. If this is not posible directly you might have to write a VB Script or something similar to do the actual renaming once the registry runs your command on startup.

Hope this helps you.

Vytautas :)


I don't think that will work. Usually installers use rename on reboot to replace system files. To replace 'em, the system files should not be in use.


Originally posted by Joost Verburg
I don't think that will work. Usually installers use rename on reboot to replace system files. To replace 'em, the system files should not be in use.
Is there a way to emulate a system file, e.g. make sure it is used like a systems file, so that I could test a script to see if I can get some sort of a solution for this problem?

Vytautas

SprinklerHead, what version of NSIS are you using? What is the code you are using? Are you using the UpgradeDLL macro or something else?


Kichik, I am using NSIS version 2.03B. I am not using the upgradedll macro. Here is an example of the code I am using.


Section
!insertmacro CopyLockedFile FullUpdater.exe $INSTDIR\SYSTEM "${FilesDir}"
SectionEnd

;-----------------------------------------
; CopyLockedFile
;-----------------------------------------
; Attempts to copy a file. If the file could not be copied, then
; the file is copied to a temporary location and copied to
; its proper directory after a reboot.
;-----------------------------------------
!macro CopyLockedFile FILE_NAME OUTPUT_PATH LOCAL_PATH
Push $R1

ClearErrors

; Try to copy the file.
SetOutPath ${OUTPUT_PATH}
SetOverwrite Try
File "${LOCAL_PATH}\${FILE_NAME}"
SetOverwrite On

; If we got an error copying, then the file was in use.
IfErrors FileNotCopied ExitOut

; The file could not be copied, most likely because it was in use.
FileNotCopied:
; Create a temporary file. The name of this file will be unique.
; The name will be stored in $R1.
GetTempFileName $R1

; Copy the output file over the temporary file we just created.
; For example, this would copy asteel2.exe to j2iofawer.atj
; (or some other unique temp file name).
File /oname=$R1 "${LOCAL_PATH}\${FILE_NAME}"

; Rename and copy the temp file ($R1) to the actual destination,
; renaming it to the proper name.
; If a reboot is required (probably always), set the reboot flag.
Rename /REBOOTOK $R1 "${OUTPUT_PATH}\${FILE_NAME}"

ExitOut:
Pop $R1
!macroend

It's not a NSIS related issue, wininit.ini doesn't support it. Other installers have the same limitation.


The Windows API GetShortPathName() might help here. Maybe NSIS should automatically use this to get the short path name when doing the reboot related stuff.


MoveFileOnReboot does use GetShortPathName because it's required in wininit.ini. The problem is that for some bizarre reason Windows actually uses the short file name and removes the long file name completely. I am currently looking into workarounds for this.


Originally posted by Sunjammer
The Windows API GetShortPathName() might help here. Maybe NSIS should automatically use this to get the short path name when doing the reboot related stuff.
Windows automatically converts it to a short filename, as you have descripted in your post.