使用下面的代码,我可以创建一个带有密码的用户,但是如何启用“密码永不过期”标志?

using (var process = new Process())
{
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = false;
process.StartInfo.UseShellExecute = true;
process.StartInfo.Arguments = $"user test-user Password1 /add";
process.StartInfo.FileName = "net";
process.Start();
process.WaitForExit();
}发布于 2019-12-06 14:28:06
net user documentation说有一个expires选项可以与never一起使用,如下所示:
process.StartInfo.Arguments = $"user test-user Password1 /add /expires:never";但是您可能不应该在C#代码中使用net user,这是在有替代方法时调用shell进程的糟糕做法。
https://stackoverflow.com/questions/59207907
复制相似问题