i have a small application to configure IIS using Process.StartInfo. The application works fine in Windows 2008 R2 64-bit and all the 32-bit machines. I dont see much differensce even if i use Runas. The application is run as local admin on the box.
the code is below
namespace ConsoleApplication1 {
class Program
{
private const string configIISParameters2012 = "/k START /w C:\\Windows\\SysNative\\PKGMGR.EXE /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;
private const string exeCommand = "CMD.EXE";
static void Main()
{
RunCommand(exeCommand, configIISParameters2012);
}
public static bool RunCommand(String command, String arguments)
{
bool ret = false;
try
{
System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
startInfo.CreateNoWindow = true;
startInfo.Verb = "unas";
startInfo.FileName = command;
startInfo.Arguments = arguments;
process.StartInfo = startInfo;
process.StartInfo.UseShellExecute = true;
process.EnableRaisingEvents = true;
process.Start();
process.WaitForExit();
process.Close();
ret = true;
}
catch (Exception ex)
{
//Utility.Log("Exception executing command :" + ex.StackTrace);
}
return ret;
}