Matin Lotfaliee
Matin Lotfaliee

Reputation: 1615

How to process a string in NSIS?

I have a string from the parameters that has a installation path using this code:

${GetParameters} $R0
${if} $R0 != ""
    StrCpy $R1 $R0 "" 3
    StrCpy $INSTDIR $R1 -1          
${endif}

the $INSTDIR contains a path like this:

C:\Program Files (x86)\My Applicatoin

I want to get "My Application" out of it and save it in a variable. I know that I should check the characters backwards until i reach the backslash ( \ ) but I do not know how to implement it in NSIS syntax.

How can I get "My Application" from the folder path using NSIS?

Upvotes: 1

Views: 1174

Answers (1)

Anders
Anders

Reputation: 101666

Most string operations can be coded with just StrCpy, StrCmp and StrLen.

A basic version that only checks \ and not / already exists:

!include FileFunc.nsh
StrCpy $0 "C:\Program Files (x86)\My Application"
${GetFileName} $0 $1
DetailPrint $1

Upvotes: 2

Related Questions