如何取得安装程序本身文件名中的特定字符串,比如IP地址。经过讨论,我们得出两种方法实现需求,分别对应需要取得的字符串(IP地址)在不同位置的两种情况。
一、IP地址在前且后面的字符串长度固定,比如192.8.205.191-install.exe
Name "获取文件名中的字符串一" Caption "$(^Name)" OutFile "192.8.205.191-install.exe" XPStyle on Section StrLen $R1 $EXEFILE IntOp $R1 $R1 - 12 StrCpy $R0 $EXEFILE $R1 MessageBox MB_OK "IP:$R0" SectionEnd
二、IP地址在中间且前后有特定字符,比如client-192.8.205.191-install.exe
Name "获取文件名中的字符串二" Caption "$(^Name)" OutFile "client-192.8.205.191-install.exe" XPStyle on !include "WordFunc.nsh" Section ${WordFind2X} "$EXEFILE" "-" "-" "-1" $R0 MessageBox MB_OK "IP:$R0" SectionEnd