assign logon scripts to local users
Posted
by user311130
on Stack Overflow
See other posts from Stack Overflow
or by user311130
Published on 2010-05-06T06:35:18Z
Indexed on
2010/05/06
6:38 UTC
Read the original article
Hit count: 489
Hello,
I wrote a c# code that creates new local user
DirectoryEntry localMachine = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer");
DirectoryEntry group = localMachine.Children.Find("administrators", "group");
DirectoryEntry user = localMachine.Children.Find(accountName, "user");
Console.WriteLine(user.Properties.ToString());
I tried to set the logon script for that user by doing:
localMachine.Properties["scriptPath"].Insert(0, "logonScript.vbs"); localMachine.CommitChanges();
same with group or user instances.but the property doesn't exist in any of theses instances (localMachine, group or user). I know that because I did:
System.Collections.ICollection col = localMachine.Properties.PropertyNames;
foreach (Object ob in col) { Console.WriteLine(ob.ToString()); }
Any idea of how to do that in other way?Cheers,
© Stack Overflow or respective owner