|
|
|
|
#1 |
|
Junior Member
Join Date: Jun 2006
Posts: 8
|
NSIS Check if directory exists
Greetings,
the last couple of weeks, I have been fooling arround with NSIS and taken the initiative to convert all related work to it as it would be easier to have the option of starting up the single installer that would take care of all the other installations required to be done (various agent software and OS tweaking ..)now there are several subjects im facing some dificulties with, I hope some of you guys here could help me out. due to the different operating systems and versions that are administered, I need to be able to verify whether a directory in a given path exists so i can continue processing other tasks based on that, how and what is the best way for this to be accomplished, for example, i need to find out whether c:\admtools exists or c:\foobar exists, if it does then a variable would be flagged (myfoldervar=1) ive tried to lookup in the forum, but i didnt find any clear answer to this, hoping to hear from the pros soon, regards BL |
|
|
|
|
|
#2 | |
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
Re: NSIS Check if directory exists
Quote:
Use the IfFileExists instruction. |
|
|
|
|
|
|
#3 |
|
Junior Member
Join Date: Jun 2006
Posts: 8
|
yes i noticed that "if file exist" feature, i just wanst sure whether it is the appropriate one giving it a thought whehter "if directory exist" method exists as well
|
|
|
|
|
|
#4 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
IfFileExists "$INSTDIR\directory\*.*" ...
-Stu |
|
|
|
|
|
#5 | ||
|
NSIS Dev
Join Date: Feb 2003
Location: Boston, MA, U.S.A.
Posts: 455
|
Quote:
Quote:
|
||
|
|
|
|
|
#6 |
|
Junior Member
Join Date: Jun 2009
Posts: 6
|
Is there a way to know is it a file or directory?
|
|
|
|
|
|
#7 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Did you miss my code?
Same idea but using LogicLib: code: Edit: Note the order of checks is important. Stu |
|
|
|
|
|
#8 |
|
Junior Member
Join Date: Jun 2009
Posts: 6
|
Thanks for the answer!
But I have found the winapi function: http://nsis.sourceforge.net/GetFileAttributes Good luck! |
|
|
|
|
|
#9 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Why use that when you can just use the simple logic I gave?
Stu |
|
|
|
|
|
#10 |
|
Junior Member
Join Date: Jun 2009
Posts: 6
|
First I thought, that empty dir will be detected as file.
But then I trieed everything is OK. Thank you so much! |
|
|
|
|
|
#11 |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Yes people are misled by the use of *.* but it does cover empty directories because . is the current directory and .. is the parent directory (you will pick up . and .. as files when using FindFirst, FindNext etc).
Stu |
|
|
|
|
|
#12 |
|
Senior Member
Join Date: Mar 2006
Location: United States
Posts: 109
|
But isn't possible to use a wildcard search on the folder level, is it, thus checking for the existence of multiple folders perhaps with similar names?:
${If} ${FileExists} `$INSTDIR\file*\*.*` |
|
|
|
|
|
#13 |
|
Major Dude
Join Date: Mar 2003
Posts: 571
|
The NSIS User Manual describes several useful functions, including "Locate" which supports wildcards:
http://nsis.sourceforge.net/Docs/AppendixE.html#E.1.2 Section E.1.2 of the manual also mentions the "Locate" plugin which supports wildcards: http://nsis.sourceforge.net/Locate_plugin |
|
|
|
|
|
#14 |
|
Senior Member
Join Date: Mar 2006
Location: United States
Posts: 109
|
Thank you. I will take a look at it. Some of these things are much simpler when I am doing them in a C++ context. I find myself asking basic questions when it comes to the installer.
|
|
|
|
|
|
#15 |
|
Junior Member
Join Date: Feb 2015
Posts: 1
|
|
|
|
|
|
|
#16 | |
|
Moderator
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
|
Quote:
Stu |
|
|
|
|
![]() |
|
|||||||
| Thread Tools | Search this Thread |
| Display Modes | |
|
|