Click here to Skip to main content
15,885,878 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to open the local group policy editor through programmatic using C#.net, which namespace is required.
Posted

Hi

Please try this.

C#
ProcessStartInfo startInfo = new ProcessStartInfo();
          startInfo.FileName = "gpedit.msc";
          Process.Start(startInfo);
 
Share this answer
 
We can do the same thing another way, this solutions is applicable to single printer. we can do this entire procedure in command prompt using console application.
sample code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.IO;

namespace GroupPolicyEdit
{
class Program
{
static void Main()
{
cmdProcess();
Console.ReadLine();
}
static void cmdProcess()
{
try
{
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "cmd.exe";
startInfo.CreateNoWindow = false;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardInput = true;
startInfo.RedirectStandardOutput = true;
Process p = new Process();
p.StartInfo = startInfo;
p.Start();
using (StreamWriter writer = p.StandardInput)
{
// If the streamwriter is able to write
if (writer.BaseStream.CanWrite)
{
// Write the command that was passed into the method
string cmd = @"printui /Xs /n ""Printer Name"" ClientSideRender enabled";
writer.WriteLine(cmd);

}
// close the StreamWriter
writer.Close();
}
}
catch { }
}

}
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900