.net - How to programatically update group policy with C#? i.e. gpupdate /force -


i have several local accounts created @ install time c#. there group policy in turn grants permissions these new accounts.

the problem trying solve how go getting group policy pushed new accounts. without group policy applied application not function.

opening cmd prompt , running gpupdate /force fixes it, need more seamless transition between install time , run time.

that should trick:

    private void updategrouppolicy()     {         fileinfo execfile = new fileinfo("gpupdate.exe");         process proc = new process();         proc.startinfo.windowstyle = processwindowstyle.hidden;         proc.startinfo.filename = execfile.name;         proc.startinfo.arguments = "/force";         proc.start();         //wait gpupdate finish         while (!proc.hasexited)         {             application.doevents();             thread.sleep(100);         }         messagebox.show("update procedure has finished");     } 

Comments

Popular posts from this blog

Issues changing the value of an element in an array in matlab -

php - MySQLi binding parameters in a prepared statement doesn't work unless inserted after "WHERE" -

vb.net - Alternative to the T-SQL AS keyword -