FreeRDP使用,快速找出账户密码不正确的服务器地址

最近有个需求,需要找出服务器未统一设置账户密码的服务器,进行统一设置,一共有一百多台服务器,一个个远程登录看,那得都费劲啊,这时候就可以用到FreeRDP这个远程桌面协议工具,FreeRDP下载,根据自己的需要下载,我是windows10 64位系统就下载了个wfreerdp,下载好了之后就可以写代码了

cs 复制代码
            
            string wfreerdpExecutablePath = "wfreerdp.exe";

            string[] serverRecords = File.ReadAllLines("server.csv");

            foreach (string record in serverRecords)
            {
                string[] serverData = record.Split(',');

                if (serverData.Length != 3)
                {
                    continue;
                }

                string ipAddress = serverData[0];
                string userName = serverData[1];
                string userPassword = serverData[2];

                // 构建wfreerdp命令行参数
                string rdpArguments = $"/v:{ipAddress} /u:{userName} /p:{userPassword}";

                try
                {
                    ProcessStartInfo processInfo = new ProcessStartInfo(wfreerdpExecutablePath, rdpArguments);
                    processInfo.CreateNoWindow = true;
                    processInfo.UseShellExecute = false;

                    using (Process rdpProcess = Process.Start(processInfo))
                    {
                        rdpProcess.WaitForExit();

                        int exitCode = rdpProcess.ExitCode;

                        if (exitCode == 0)
                        {
                            Console.WriteLine($"{ipAddress}远程桌面连接成功启动");
                        }
                        else
                        {
                            Console.WriteLine($"{ipAddress}远程桌面连接失败,退出代码:{exitCode}");
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"{ipAddress}启动远程桌面时发生错误:{ex.Message}");
                }
            }

为了读取简单就搞了个csv文件,根据ip,账户,密码三个字段进行填写就好了,程序会啪嗒啪嗒地打开远程桌面,电脑配置不好的会卡,我的烂电脑就卡了,所以最好把服务器信息分批进行读取运行😂

相关推荐
不爱学习的啊Biao10 分钟前
C# 下sendmessage和postmessage的区别详解与示例
开发语言·c#
yizhou201014 分钟前
C# Winform项目中简单使用Sqlite并在DataGridview中显示
sqlite·c#
Lingoesforstudy2 小时前
c#中的超时终止
开发语言·笔记·c#
J-SL2 小时前
C#接口一些有意思的东西
c#
V言微语4 小时前
2.5 C#视觉程序开发实例1----CamManager实现模拟相机采集图片
开发语言·数码相机·c#
mosi3575 小时前
使用C#进行MySQL删改查操作
mysql·c#
hello-alien7 小时前
ASP.NET Core----基础学习04----Model模型的创建 & 服务的注入
学习·c#·asp.net·model
mrchip7 小时前
Simple WPF: WPF 实现按钮的长按,短按功能
c#·wpf·.net core
WineMonk8 小时前
ArcGIS Pro SDK (七)编辑 13 注解
arcgis·c#·gis·arcgis pro sdk
j.king15 小时前
开源GTKSystem.Windows.Forms框架让C# winform支持跨平台运行
linux·c#·gtk