How to create empty file with NSIS
Asked Answered
L

2

5

In my installer I would like to create an empty file. In linux I would use the touch command, but what's the easiest way to do this in NSIS?

Loathsome answered 6/9, 2011 at 6:56 Comment(0)
G
13
#Compile time
!appendfile "$%temp%\compiletimefile.txt" ""

;Or if you need to force the file to be empty
!appendfile "$%temp%\compiletimefile.txt" ""
!delfile "$%temp%\compiletimefile.txt"
!appendfile "$%temp%\compiletimefile.txt" ""


#Run time, method 1
FileOpen $0 "$temp\runtimefile1.txt" w
FileClose $0


#Run time, method 2
File "/oname=$temp\runtimefile2.txt" "$%temp%\compiletimefile.txt"
Grison answered 6/9, 2011 at 11:5 Comment(1)
Thanks for your solution. I wasn't aware of the !appendfile command.Loathsome
A
0

Use this simple code to create an empty file. Also, it helps a lot for debugging when you place it in any function block.

StrCpy $9 "hello world"
FileOpen $8 "$DESKTOP\test_1.txt" w ;Opens a Empty File and fills it
FileWrite $8 "$9"
FileClose $8 ;Closes the filled file
Activator answered 12/8, 2021 at 11:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.