Old 7th June 2019, 05:35   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Post Get the first free drive letter

I am trying with code:

code:
Var FirstFreeLetter
${For} $0 A Z
IfFileExists $0\*.* 0 Done
StrCpy $FirstFreeLetter $0
${ExitFor}
Done:
${Next}



but not success.

Thanks.
meoit is offline   Reply With Quote
Old 7th June 2019, 09:09   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 881
Have you tried one wildcard instead of *.*?

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 7th June 2019, 14:11   #3
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,165
The drive root is a bit special, there is no ".." directory.

"\*" detects directory and/or root.

"\?" detects directory but not root?

"\." detects something but I don't remember what exactly.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 7th June 2019, 20:02   #4
ahmett
Junior Member
 
Join Date: Jan 2008
Posts: 21
var /global comspec
ExpandEnvStrings $comspec "%COMSPEC%"
nsexec::exectostack '"$comspec" /C wmic logicaldisk get size,freespace,caption'
Pop $0
Pop $0
${WordFind} "$0" "$\n" "*" $1
${For} $2 1 $1
${WordFind} "$0" "$\n" "+$2" $3
${WordFind} "$3" ":" "+1}" $4
${if} $3 != $4
${WordFind} "$3" " " "+1" $4
${WordFind} "$3" " " "+2" $5
${WordFind} "$3" " " "+3" $6
Math::Script 'r7 = f((r6=r6/1048576)-(r5=r5/1048576))'
Strcmp $7 0 +2
detailprint "Drive $4 Total:$6MB Free:$5MB Used:$7MB"
${endif}
${Next}
ahmett is offline   Reply With Quote
Old 8th June 2019, 12:52   #5
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Smile

OK. Now it's working.

code:

StrCpy $0 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
StrCpy $1 0
start:
StrCpy $2 $0 1 $1
StrCmp $2 '' end
IntOp $1 $1 + 1
;MessageBox MB_OK '$$0={$0}$\n$$1={$1}$\n$$2={$2}'
${If} ${FileExists} '$2:\*'
Goto start
${Else}
StrCpy $0 '$2:'
Goto end
${EndIf}
end:
MessageBox MB_OK|MB_USERICON '$0'

meoit 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