Archive: FileOpen doesn't work


FileOpen doesn't work
  I try to open a file with FileOpen. But it does not work. With my Explorer I am able to open that file with no problems. The file is created during the procedure by a vbscript (yes, that's nessesary).

Here is my NSIS Code

SetOverwrite on


SetOutPath "$INSTDIR\tmp"

File "${BIN}\ImportAssistentScript.vbs"
File "${BIN}\ZertifikatImport.vbs"
File "${BIN}\ZertifikatsKonsole.msc"

;privates zertifikat in den speicher laden über die skripte
Exec 'cscript "$INSTDIR\tmp\ImportAssistentScript.vbs" "$private_crt" "$pwd"'
ExecWait 'cscript "$INSTDIR\tmp\ZertifikatImport.vbs" "$INSTDIR\tmp\ZertifikatsKonsole.msc" "$INSTDIR"'

Delete "${BIN}\ImportAssistentScript.vbs"
Delete "${BIN}\ZertifikatImport.vbs"
Delete "${BIN}\ZertifikatsKonsole.msc"

;datei tmp.txt wird im script geschrieben.
StrCpy $R1 "$INSTDIR\tmp.txt"

FileOpen $0 $R1 "r" ;hier tritt ein fehler auf. warum???
IfErrors error1

FileRead$0 $1
IfErrors error2

MessageBox MB_OK "Datei-Inhalt '$1'"

FileClose $0
goto done

error1:
MessageBox MB_OK "fehler beim öffnen der datei: '$R1'"
goto done

error2:
MessageBox MB_OK "fehler beim lesen der datei"
goto done

done:

Quit
>
It's only a testing part. First I copy the vbscript files to the instdir to run them on the target computer. after they are executed I delete the files. At this time, the file tmp.txt allready exists. But FileOpen fails. I have absolutely no idea why!

For those who can script vb here's the part of writing the file in vbscript.

Dim zertName

zertName= objView.CellContents(objItem, 1)

>Ergebnis in temp datei speichern
Dim objFSO
, file
Set objFSO= CreateObject("Scripting.FileSystemObject")
>Set file = objFSO.CreateTextFile(path + "\tmp.txt", true)
>file.WriteLine(zertName)
>file.Close()
I think, that this is not a NSIS Problem. But I don't know anyone who could help me... :cry:

I have to write

FileOpen $0 "$R1" "r" ;hier tritt ein fehler auf. warum???

instead of

FileOpen $0 $R1 "r" ;hier tritt ein fehler auf. warum???


Try:
ClearErrors
FileOpen $0 $R1 "r" ;hier tritt ein fehler auf. warum???
IfErrors error1

-Stu


Also, I think the Delete's should be:
Delete "$INSTDIR\tmp\ImportAssistentScript.vbs"
Delete "$INSTDIR\tmp\ZertifikatImport.vbs"
Delete "$INSTDIR\tmp\ZertifikatsKonsole.msc"

-Stu


Originally posted by Afrow UK
Also, I think the Delete's should be:
Delete "$INSTDIR\tmp\ImportAssistentScript.vbs"
Delete "$INSTDIR\tmp\ZertifikatImport.vbs"
Delete "$INSTDIR\tmp\ZertifikatsKonsole.msc"

-Stu
Oh yes! You're right. Thanks!!