xshell7 无法打开 提示"要继续使用此程序,您必须应用最新的更新或使用新版本" 解决方案

情况

打开xshell7 提示要继续使用此程序,您必须应用最新的更新或使用新版本
image

解决方案

  • 临时方案-重置时间大法
  • 重装xshell (但是也得导出之前的配置)
  • 更换shell工具-MobaXterm

1.临时方案-重置时间打开xshell

新建文件startXShell.bat 拷贝下面内容

注意替换xshell 路径 "D:\Program Files\Xshell\Xshell.exe"

启动请用管理员权限运行

@echo off
%1 mshta vbscript:CreateObject("Shell.Application").ShellExecute("cmd.exe","/c %~s0 ::","","runas",1)(window.close)&&exit 
 
date 2022-10-1
 
start ""  "D:\Program Files\Xshell\Xshell.exe"
 
echo 启动软件中...
ping 0.0.0.0 -n 10> null
echo 同步时间中,完成后自动关闭窗口...
 
w32tm /resync
exit
 

2.导出xshell 配置并转换

xshell 文件导出,注意选择csv格式
导出默认不带密码,在MobaXterm输入一次后会保存

写了个小脚本生成MobaXterm配置文件
linqPad可以直接跑

void Main()
{  
	var xshellSessionDirectory = @"E:\Downloads\Compressed\xshell\";
	var savePath = xshellSessionDirectory;
	if (!Directory.Exists(xshellSessionDirectory))
	{
		Console.WriteLine("目录不存在:" + xshellSessionDirectory);
		return;
	}

	var sb = new StringBuilder();
	Generate(xshellSessionDirectory, sb, xshellSessionDirectory);
	File.WriteAllText($"{savePath}\\Sessions.mxtsessions", sb.ToString(), Encoding.GetEncoding("GB2312"));
	Console.WriteLine("转换完成");
}

int _idx = 0;
int GetNextId() => _idx++;

public class ServerInfo
{
	public string Name { get; set; }
	public string IP { get; set; }
	public string Type { get; set; }
	public int Port { get; set; }
	public string UserName { get; set; }
}

// You can define other methods, fields, classes and namespaces here
void HandleDirectory(string rootDirectory, StringBuilder sb, string directory, int id)
{
	if (id <= 0)
	{
		sb.AppendLine("[Bookmarks]");
		sb.AppendLine("SubRep=");
		sb.AppendLine("ImgNum=42");
		//sb.AppendLine("WSL-Ubuntu=#105#14%1%");
		sb.AppendLine("WSL-Ubuntu-22.04=#105#14%Ubuntu-22.04%"); 
	}
	 
	var sessionFiles = Directory.GetFiles(directory, "*.csv");
	foreach (var sessionFile in sessionFiles)
	{
		var fileName = Path.GetFileNameWithoutExtension(sessionFile);
		using (var reader = new StreamReader(sessionFile,Encoding.Default))
		using (var csv = new CsvReader(reader, CultureInfo.CurrentCulture))
		{
			var records = csv.GetRecords<ServerInfo>();
			foreach (var item in records)
			{
				if (item.Type == "SSH")
				{
					sb.Append("#-1");
					sb.AppendLine();
					sb.Append($"{item.Name.Trim()}= #{"109"}#0%{item.IP}%{item.Port}%{item.UserName}%%-1%-1%%%%%0%0%0%%%-1%0%0%0%%1080%%0%0%1%#MobaFont%10%0%0%-1%15%236,236,236%30,30,30%180,180,192%0%-1%0%<>%xterm%-1%0%_Std_Colors_0_%80%24%0%1%-1%<none>%%0%0%-1%-1#0#");
					sb.AppendLine();
				}
			} 
			
			sb.AppendLine();
			sb.AppendLine();
		} 
	} 
}

void Generate(string rootDirectory, StringBuilder sb, string directory)
{
	var items = Directory.GetFileSystemEntries(directory);
	HandleDirectory(rootDirectory, sb, directory, GetNextId());

	foreach (var item in items)
	{
		var attr = File.GetAttributes(item);
		if (attr.HasFlag(FileAttributes.Directory))
		{
			Generate(rootDirectory, sb, item);
		}
	}
}

只转化了SSH,其他请自己适配下

3.更换为MobaXterm

MobaXterm 官网下载免费版本即可,注意无中文

右键直接导入生成的文件即可
image

posted @ 2022-10-08 17:53  LandWind  阅读(11297)  评论(0编辑  收藏  举报