; 定义安装程序名称和输出文件
Name "iperf3 GUI"
OutFile "iperf3 GUI.exe"
RequestExecutionLevel user ; 请求用户权限级别
InstallDir "$TEMP\iperf3_gui" ; 设置安装目录(临时目录)
Icon SL.ico
VIProductVersion "1.0.0.0" ;版本号
VIAddVersionKey /LANG=2052 "ProductName" "简单网管工具" ;文件描述
VIAddVersionKey /LANG=2052 "Comments" "顺艺科技" ;备注
VIAddVersionKey /LANG=2052 "CompanyName" "www.jywangluo.cn"
VIAddVersionKey /LANG=2052 "LegalCopyright" "自由传播" ;版权
VIAddVersionKey /LANG=2052 "FileDescription" "简单网管工具" ;产品名称
VIAddVersionKey /LANG=2052 "FileVersion" "1.0.0.0" ;文件版本
VIAddVersionKey /LANG=2052 "ProductVersion" "1.0.0.0" ;产品版本
VIAddVersionKey /LANG=2052 "OriginalFilename" "iperf3 GUI.exe" ;源文件名
!include "nsDialogs.nsh"
BrandingText "简单网管工具 iperf3 GUI"
Caption "iperf3_GUI"
; 定义界面
Page custom nsDialogsPage
; 定义变量
Var hwnd
Var ipAddress
Var serverBtn
Var clientBtn
Var infoLabel
; 初始化
Function .onInit
SetOutPath "$INSTDIR"
File "iperf3.exe" ; 确保 iperf3.exe 在脚本同一目录下
File "cygwin1.dll"
FunctionEnd
; 创建自定义页面
Function nsDialogsPage
; 使用标准样式创建对话框,确保自定义控件能正确显示
nsDialogs::Create 1018
Pop $hwnd
${If} $hwnd == error
Abort
${EndIf}
; === 隐藏标准导航按钮 ===
; 查找并隐藏"取消"按钮 (ID通常为2)
GetDlgItem $1 $HWNDPARENT 2
ShowWindow $1 ${SW_HIDE}
; 查找并隐藏"下一步"按钮 (ID通常为1)
GetDlgItem $1 $HWNDPARENT 1
ShowWindow $1 ${SW_HIDE}
; === 隐藏完成 ===
; 创建提示标签 - 新增代码
${NSD_CreateLabel} 20% 5% 60% 13u "请输入服务端IP:"
Pop $infoLabel
; 创建 IP 地址输入框
${NSD_CreateText} 20% 18% 50% 12u ""
Pop $ipAddress
${NSD_SetText} $ipAddress "127.0.0.1" ; 默认 IP 地址
; 创建服务端按钮
${NSD_CreateButton} 20% 36% 50% 20u "启动服务端"
Pop $serverBtn
${NSD_OnClick} $serverBtn StartServer
; 创建客户端按钮
${NSD_CreateButton} 20% 56% 50% 20u "启动单线程客户端"
Pop $clientBtn
${NSD_OnClick} $clientBtn StartClient
; 创建客户端按钮
${NSD_CreateButton} 20% 76% 50% 20u "启动20线程客户端"
Pop $clientBtn
${NSD_OnClick} $clientBtn StartClient20
nsDialogs::Show
FunctionEnd
; 启动服务端函数
Function StartServer
SetOutPath "$INSTDIR"
Exec '"cmd.exe" /c "ipconfig & $INSTDIR\iperf3.exe -s"'
FunctionEnd
; 启动客户端函数
Function StartClient
${NSD_GetText} $ipAddress $0 ; 获取输入的 IP 地址
SetOutPath "$INSTDIR"
Exec '"$INSTDIR\iperf3.exe" -c $0 -t 30' ; 执行 iperf3 客户端命令
FunctionEnd
; 启动客户端函数
Function StartClient20
${NSD_GetText} $ipAddress $0 ; 获取输入的 IP 地址
SetOutPath "$INSTDIR"
Exec '"$INSTDIR\iperf3.exe" -c $0 -P 20 -t 30' ; 执行 iperf3 客户端命令
FunctionEnd
; 安装部分
Section "Install"
; 安装操作已在.onInit中完成
SectionEnd
Function .onGUIEnd
SetOutPath $TEMP
RMDir /r "$INSTDIR"
FunctionEnd
@来自无忧