Old 21st April 2020, 14:28   #1
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
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 is offline   Reply With Quote
Old 21st April 2020, 14:41   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
What makes you think it is wrong?

NSIS just returns the result of a shell folder function.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 14:52   #3
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
so a windows error.

MS\Windows\Templates
does not exist.

File should actually come up with an error.
Can you catch file errors?
RainerHH is offline   Reply With Quote
Old 21st April 2020, 15:28   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
Windows version?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 16:10   #5
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
Win10
RainerHH is offline   Reply With Quote
Old 21st April 2020, 18:48   #6
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
NSIS does a little attempt to create the folder but it is expected that your code looks like this:

Quote:
SetOutPath $TEMPLATES ; Calls CreateDirectory
File MyTemplate.ext
If you do "SetOverwrite try" then File will not give any errors.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 19:14   #7
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
overwrite ist Default, on.
RainerHH is offline   Reply With Quote
Old 21st April 2020, 19:31   #8
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
Could you maybe add some example code?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 19:38   #9
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
it's so simple
SetoutPath $Templates
File any.exe

Problem is,
Templates Path not exist
-> no error
RainerHH is offline   Reply With Quote
Old 21st April 2020, 19:45   #10
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
Quote:
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:
Quote:
SetOutPath $temp
StrCpy $OutDir "$temp\doesnotexist"
File "${__FILE__}"
I get a retry/abort/ignore messagebox.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 19:50   #11
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
what do you mean by works well?
The path MS \ Windows \ Templates doesn't exist, so it can't work well !?
RainerHH is offline   Reply With Quote
Old 21st April 2020, 19:55   #12
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 20:01   #13
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
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.
RainerHH is offline   Reply With Quote
Old 21st April 2020, 20:22   #14
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
Well, then I don't understand what you want. The directory has to exist if you want to extract a file there.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 20:23   #15
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
yes
RainerHH is offline   Reply With Quote
Old 21st April 2020, 20:31   #16
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
IfFileExists
ist usable
RainerHH is offline   Reply With Quote
Old 21st April 2020, 20:43   #17
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,282
Quote:
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 21st April 2020, 20:47   #18
RainerHH
Junior Member
 
Join Date: Apr 2020
Posts: 22
ok thanks for your efforts!
RainerHH is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump