110,533
社区成员
发帖
与我相关
我的任务
分享
using System;
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace c2
{
class Program
{
static void Main(string[] args)
{
string[] users = Regex.Split(Regex.Match(runcmd("net user"), @"(?<=-\s)[\w\s]+(?=命令成功完成)").Value.Trim(), @"\s+");
foreach (string u in users)
Console.WriteLine(u);
Console.ReadKey();
}
private static string runcmd(string command)
{
Process p = new Process();
p.StartInfo.FileName = "cmd.exe";
p.StartInfo.Arguments = "/c " + command;
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardInput = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.Start();
return p.StandardOutput.ReadToEnd();
}
}
}