Error creating frontpage extensions

A

Anders Aleborg

I have a website where my projects DLL has maximum trust and the website
runs under an admin account!
I get this error:
Error: You have to be a machine admin to perform this operation.

I've seen this code working with ASP and
Server.CreateObject("WScript.Shell")
Why doesn't it work with C#?

This is my code:

public class FrontPageWeb
{
System.Diagnostics.ProcessStartInfo startinfo;
System.Diagnostics.Process process = null;
string stdoutline;
System.IO.StreamReader stdoutreader;
private string username,website,fp,exe;
public string Username
{
set{username=value;}
}
public string WebSiteNumber
{
set{website=value;}
}
public string Activate()
{
exe = @"C:\Program Files\Common Files\Microsoft Shared\web server
extensions\50\bin\owsadm.exe";
fp = " -o install -u "+username+" -t msiis -m "+website+" -p 80";
try
{
startinfo = new System.Diagnostics.ProcessStartInfo();
startinfo.FileName = exe;
startinfo.Arguments = fp;
startinfo.UseShellExecute = false;
startinfo.RedirectStandardOutput = true;
startinfo.CreateNoWindow = true;
process = System.Diagnostics.Process.Start(startinfo);
stdoutreader = process.StandardOutput;
System.Text.StringBuilder stdoudtotal = new System.Text.StringBuilder("");
while((stdoutline=stdoutreader.ReadLine())!= null)
{
stdoudtotal.Append( "> " + stdoutline.ToString() + "\n" );
}
stdoutreader.Close();
stdoutreader = null;
if ( process.ExitCode == 0 )
{
return stdoudtotal.ToString();
}
else
{
return stdoudtotal.ToString();
}
}
catch(System.Exception exc)
{
return exc.ToString();
}
finally
{
if (process != null)
{
process.Close();
}
process = null;
startinfo = null;
}
}
}

Regards
Anders
 
A

Anders Aleborg

Yes I know it's dangerous but know it's only for testing!
The site has execute permissions and a simple "dir" works!

Regards
Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top