<#
搜索抖音用户1062745995或小红书搜索用户2290115436,把详细需求留在评论区即可免费代写脚本
#>
$configPath = ".\config.ini"
$dataArray = Read-Host "请输入新的Host Port ViewIP(以空格隔开)"
# 构造新的参数
$newHost = "Host=" + $dataArray.Split(" ")[0]
$newPort = "Port=" + $dataArray.Split(" ")[1]
$newViewIP = "ViewIP" + $dataArray.Split(" ")[2]
# 获取原文件内容
$oldContent = Get-Content -Raw -Path $configPath
# 正则匹配旧的参数
$oldHost = [regex]::Match($Content,"Host=.*").value
$oldPort = [regex]::Match($Content,"Port=.*").value
$oldViewIP = [regex]::Match($Content,"ViewIP=.*").value
# 将旧的文件内容中旧的参数替换为新的参数
$newContent = $oldContent.Replace($oldHost, $newHost).Replace($oldPort, $newPort).Replace($oldViewIP, $newViewIP)
# 将新的文件内容写入原来的文件
Set-Content -Path $configPath -Value $newContent