Skip to content
⌘ NSIS Forum Archive

Checking if $TEMPLATES exists

18 posts

RainerHH#

Checking if $TEMPLATES exists

I think the var $TEMPLATES does not provide the correct result.

It should provide the user's temporary directory, which is:

C:\users\user\AppData\Roaming\Microsoft\Templates

But it delivers:

C:\users\user\AppData\Roaming\Microsoft\Windows\Templates
RainerHH#
so a windows error.

MS\Windows\Templates
does not exist.

File should actually come up with an error.
Can you catch file errors?
Anders#
NSIS does a little attempt to create the folder but it is expected that your code looks like this:

SetOutPath $TEMPLATES ; Calls CreateDirectory
File MyTemplate.ext
If you do "SetOverwrite try" then File will not give any errors.
RainerHH#
it's so simple
SetoutPath $Templates
File any.exe

Problem is,
Templates Path not exist
-> no error
Anders#
SetOutPath $Templates
File "${__FILE__}"
MessageBox mb_ok "Go check $Templates"
Delete "$Templates\${__FILE__}"
Works just fine for me on Win10.

Perhaps your profile is locked down somehow? Try Process Monitor and see why it fails to create the directory.

And if I do:
SetOutPath $temp
StrCpy $OutDir "$temp\doesnotexist"
File "${__FILE__}"
I get a retry/abort/ignore messagebox.
RainerHH#
what do you mean by works well?
The path MS \ Windows \ Templates doesn't exist, so it can't work well !?
Anders#
SetOutPath $Templates will create it. If that somehow fails on your system then there is something strange with the ACLs in your profile.

What does the detail log on your instfiles page say?
RainerHH#
To be honest, I still haven't figured out where to find the detail log.

Nothing can be broken with my profile, everything works perfectly.

In addition, the directory should not be created at all. I Wish a Error If not exist.
Anders#
Well, then I don't understand what you want. The directory has to exist if you want to extract a file there.
Anders#
IfFileExists "$templates\*" ...
but it makes no sense to check. Not all of the special folders exist by default, you just create the folder if you are installing a template file.