My code below runs a specific DIR command in DOS and returns a bunch of directories. The top most will be the newest directory and is what is returned by the GetFirstStrPart function.
What I'd like to do is take that popped $R0 value and assign it to something like $NewestDir, but when I do the StrCpy, it errors out.
Any ideas?
Function InstallNewVersionsPost
ReadEnvStr $0 COMSPEC
nsExec::ExecToStack '$0 /C "dir g:\ /o-d/ad/b"'
Pop $0 # return value/error/timeout
Pop $1 # printed text, up to ${NSIS_MAX_STRLEN}
Push $1
Call GetFirstStrPart
Pop "$R0"
;StrCpy $R0 $NewestDir
ReadINIStr ${TEMP1} "$PLUGINSDIR\test.ini" "Field 7" "State"
${If} ${TEMP1} == "1"
ExecWait '"G:\$R0\mysoftware\DISK1\SETUP.EXE" -s -f1$PLUGINSDIR\install.iss'
${EndIf}
FunctionEnd
Function GetFirstStrPart
Exch $R0
Push $R1
Push $R2
StrLen $R1 $R0
IntOp $R1 $R1 + 1
loop:
IntOp $R1 $R1 - 1
StrCpy $R2 $R0 1 -$R1
StrCmp $R2 "" exit2
StrCmp $R2 "$\r" exit1 ; Change " " to "\" if ur inputting dir path str
Goto loop
exit1:
StrCpy $R0 $R0 -$R1
exit2:
Pop $R2
Pop $R1
Exch $R0
FunctionEnd