私の会社の製造部門は、事前定義済みの管理外のグループポリシーを簡単に適用または削除できるユーティリティを作成しています新鮮な機械で。この問題について細部まで詳しく説明することなく、グループポリシーは、特定のマシン上の管理者以外のユーザーのデスクトップ機能を制限します。Directory.Createで作成されたC: Windows System32 GroupPolicy Usersの下にあるフォルダが表示されない
Windowsエクスプローラを使用してC:\ Windows \ System32 \ GroupPolicyUsersフォルダ内のあるWindows 7マシンから別のマシンに手動でファイルをコピーした後、コマンドプロンプトからgpupdate/forceを呼び出すと、私が期待する。具体的には、次のフォルダをC:\ Windows \ System32 \ GroupPolicyUsers:S-1-5-32-545にコピーしています。ただし、.NETの「CreateDirectory」メソッドを使用してこのディレクトリを作成しようとすると、エクスプローラを使用してフォルダを表示しようとするとフォルダが表示されません。ディレクトリを作成した後、 "Directory.Exists"を呼び出してその存在を確認するので、フォルダが作成されていることがわかります
ここでは、私が持っている問題を説明するサンプルコードです。これを実行した後
using System;
using System.IO;
using System.Security.AccessControl;
using System.Security.Principal;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var security = new System.Security.AccessControl.DirectorySecurity();
security.AddAccessRule(
new FileSystemAccessRule(
new SecurityIdentifier(WellKnownSidType.AuthenticatedUserSid, null),
FileSystemRights.ReadAndExecute,
InheritanceFlags.None | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
security.AddAccessRule(
new FileSystemAccessRule(
new SecurityIdentifier(WellKnownSidType.LocalSystemSid, null),
FileSystemRights.ReadAndExecute,
InheritanceFlags.None | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
security.AddAccessRule(
new FileSystemAccessRule(
new SecurityIdentifier(WellKnownSidType.BuiltinAdministratorsSid, null),
FileSystemRights.ReadAndExecute,
InheritanceFlags.None | InheritanceFlags.ObjectInherit,
PropagationFlags.None,
AccessControlType.Allow));
Directory.CreateDirectory(@"C:\Windows\System32\GroupPolicyUsers\S-1-5-32-545", security);
if (Directory.Exists(@"C:\Windows\System32\GroupPolicyUsers\S-1-5-32-545"))
{
Console.WriteLine("Directory exists.");
}
else
{
Console.WriteLine("Directory does NOT exist!");
}
Console.ReadLine();
}
}
}
この新しく作成したフォルダに移動するには、Windowsエクスプローラを使用して、あなたはそれがだと表示されます。適切な権限を持っているために、「管理者として」あなたは、このサンプルコードを実行する必要がありますのでご注意くださいWindowsエクスプローラの設定で隠しファイルが表示されていても表示されません。何か案は?
ビンゴ!ありがとう、スコット! –
@ScottChamberlainあなたは答えとしてあなたのコメントを書き留めてください、私はそれを受け入れる答えにしますか?ありがとう! –