Skip to content
⌘ NSIS Forum Archive

Invalid filehandle 123

11 posts

Yathosho#

Invalid filehandle 123

whenever i'm running my script, i'm getting the error-message "Invalid file handle 123".

i've modified the line 65 of FontReg.nsh to

CopyFiles '${FontFile}' '$FONT_DIR\${FontFileName}'.

i checked the input-file for the macro and don't see why this shall not work. any clues?
Comperio#
Is ${FontFileName} an actual file name?

The reason I ask is that I thought CopyFiles needed a file name and a folder name as parameters. The way I'm reading your example, it looks as if you supplied 2 file names.
Afrow UK#
The destination parameter for CopyFiles requires the full path to the file name to be copied as.
Having a folder name works, but if that folder doesn't exist it will create the file of that folder name instead.

-Stu
Yathosho#
unfortunately, the errors still occurs. the reason why i replaced that line from FontReg.nsh is, that the font i want to install is stored in a variable.

in order to find the mistake, i replaced the variable with "path/to/font.ttf" and the error-message changes to "MappedFile error: 1006".

i've added a messagebox displaying..

${FontFile}: "C:\MyDir\myfont.ttf"
$FONT_DIR: C:\MyDir\myfont.ttf
${FontFileName}: myfont.ttf"

..please mind the quotes!

i don't understand why they get messed up like this and why i still get this error replacing the variable with a path to my font. any clues?
Yathosho#edited
it's all working now, problem was in the a later fontname macro
Yathosho#
once again i'm getting MappedFile error: 1006 when using the following script
  GetTempFileName $TempFile
ReadEnvStr $R1 COMSPEC
nsExec::Exec '"$R1" /C dir "$Input\*.ttf" /a-d /b /s /on>$TempFile"'

StrCpy $FONT_DIR $FONTS
StrCpy "$Counter" "1"

Loop:
${LineRead} "$TempFile" "$Counter" "$Line" ;${LineRead} "[File]" "[LineNumber]" $var
IfErrors PostEnd

Push $Line
Call TrimNewlines
Pop $Line

Push $Line
Call GetName
Pop $File

IfFileExists "$Line" 0 +3
MessageBox MB_OK "Yay!"
Goto +3
MessageBox MB_OK "Nay!"
Quit

!insertmacro InstallTTF "$Line"
SendMessage ${HWND_BROADCAST} ${WM_FONTCHANGE} 0 0 /TIMEOUT=5000

IntOp $Counter $Counter + 1
Goto Loop
what i don't understand about it, IfFileExists is always reporting "Yay!", but only one font from the $TempFile is being installed. once it's reading line 2 i get that error. what am i doing wrong?!
Afrow UK#
Why are you using the dir command to list the font files? Why not use FindFirst, FindNext etc. It would be much easier.

-Stu
Yathosho#
good point. i actually used this from another script of mine where i needed a sorted list (a-z) 🙂
Afrow UK#
It may be safer to use an array (NSISArray) to sort it, but dir exists on all systems to my knowledge. It's still a bit unprofessional though I'd say, as you're relying on another executable for the installer to function correctly.

Here's another thing:
You're using GetName and Popping $File from it, yet you're using $Line afterwards. Surely you should be using $File?

Congrats if this is fixed. I'm drunk 😛

-Stu