3

私は一日中答えを探していましたが、運がありませんでした。

スタンドアロンの Windows 7 PC のローカル セキュリティ ポリシーでパスワードの複雑さを無効にする必要があります。

secedit.exe でスクリプトを作成してみました。私はまた、C#を少しいじりました。

最終結果は、ポリシーを無効にして新しいユーザー アカウントをローカルに作成するスクリプト/プログラムになります。

4

1 に答える 1

3

いくつかの広範な調査の後、私はそれを行う方法を見つけました。他の誰かが使用する必要がある場合に備えて、ここにコードを投稿します。

string tempFile = Path.GetTempFileName();
Process p = new Process();
p.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\secedit.exe");
p.StartInfo.Arguments = String.Format("/export /cfg \"{0}\" /quiet", tempFile);
p.StartInfo.CreateNoWindow = true;
p.StartInfo.UseShellExecute = false;
p.Start();
p.WaitForExit();

StringBuilder newCfg = new StringBuilder();
string[] cfg = File.ReadAllLines(tempFile);

foreach (string line in cfg)
{
    if (line.Contains("PasswordComplexity"))
    {
        newCfg.AppendLine(line.Replace("1", "0"));
        continue;
    }
    newCfg.AppendLine(line);
}
File.WriteAllText(tempFile, newCfg.ToString());

Process p2 = new Process();
p2.StartInfo.FileName = Environment.ExpandEnvironmentVariables(@"%SystemRoot%\system32\secedit.exe");
p2.StartInfo.Arguments = String.Format("/configure /db secedit.sdb /cfg \"{0}\" /quiet", tempFile);
p2.StartInfo.CreateNoWindow = true;
p2.StartInfo.UseShellExecute = false;
p2.Start();
p2.WaitForExit();
于 2014-02-10T09:39:51.293 に答える