Error creating frontpage extensions

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anders Aleborg

    #1

    Error creating frontpage extensions

    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.CreateOb ject("WScript.S hell")
    Why doesn't it work with C#?

    This is my code:

    public class FrontPageWeb
    {
    System.Diagnost ics.ProcessStar tInfo startinfo;
    System.Diagnost ics.Process process = null;
    string stdoutline;
    System.IO.Strea mReader stdoutreader;
    private string username,websit e,fp,exe;
    public string Username
    {
    set{username=va lue;}
    }
    public string WebSiteNumber
    {
    set{website=val ue;}
    }
    public string Activate()
    {
    exe = @"C:\Program Files\Common Files\Microsoft Shared\web server
    extensions\50\b in\owsadm.exe";
    fp = " -o install -u "+username+ " -t msiis -m "+website+" -p 80";
    try
    {
    startinfo = new System.Diagnost ics.ProcessStar tInfo();
    startinfo.FileN ame = exe;
    startinfo.Argum ents = fp;
    startinfo.UseSh ellExecute = false;
    startinfo.Redir ectStandardOutp ut = true;
    startinfo.Creat eNoWindow = true;
    process = System.Diagnost ics.Process.Sta rt(startinfo);
    stdoutreader = process.Standar dOutput;
    System.Text.Str ingBuilder stdoudtotal = new System.Text.Str ingBuilder("");
    while((stdoutli ne=stdoutreader .ReadLine())!= null)
    {
    stdoudtotal.App end( "> " + stdoutline.ToSt ring() + "\n" );
    }
    stdoutreader.Cl ose();
    stdoutreader = null;
    if ( process.ExitCod e == 0 )
    {
    return stdoudtotal.ToS tring();
    }
    else
    {
    return stdoudtotal.ToS tring();
    }
    }
    catch(System.Ex ception exc)
    {
    return exc.ToString();
    }
    finally
    {
    if (process != null)
    {
    process.Close() ;
    }
    process = null;
    startinfo = null;
    }
    }
    }

    Regards
    Anders


  • Anders Aleborg

    #2
    Re: Error creating frontpage extensions

    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

    "Ignacio Machin" <ignacio.machin _AT_dot.state.f l.us> skrev i meddelandet
    news:ucJzWtHgDH A.3616@TK2MSFTN GP11.phx.gbl...[color=blue]
    > Hi Anders,
    >
    > Well after all the usual stuff of how dangerous it's to run a website in
    > such a way, I would do this:
    >
    > See that the web site has permission to execute executables, you check[/color]
    this[color=blue]
    > under IIS/Properties/Home Directory tab/ execute permissions
    >
    > --
    > Hope this help,
    >
    > --
    > Ignacio Machin,
    > ignacio.machin AT dot.state.fl.us
    > Florida Department Of Transportation
    >
    >
    > "Anders Aleborg" <anders@aleborg .se> wrote in message
    > news:%235sESUHg DHA.1752@TK2MSF TNGP10.phx.gbl. ..[color=green]
    > > 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.CreateOb ject("WScript.S hell")
    > > Why doesn't it work with C#?
    > >
    > > This is my code:
    > >
    > > public class FrontPageWeb
    > > {
    > > System.Diagnost ics.ProcessStar tInfo startinfo;
    > > System.Diagnost ics.Process process = null;
    > > string stdoutline;
    > > System.IO.Strea mReader stdoutreader;
    > > private string username,websit e,fp,exe;
    > > public string Username
    > > {
    > > set{username=va lue;}
    > > }
    > > public string WebSiteNumber
    > > {
    > > set{website=val ue;}
    > > }
    > > public string Activate()
    > > {
    > > exe = @"C:\Program Files\Common Files\Microsoft Shared\web server
    > > extensions\50\b in\owsadm.exe";
    > > fp = " -o install -u "+username+ " -t msiis -m "+website+" -p 80";
    > > try
    > > {
    > > startinfo = new System.Diagnost ics.ProcessStar tInfo();
    > > startinfo.FileN ame = exe;
    > > startinfo.Argum ents = fp;
    > > startinfo.UseSh ellExecute = false;
    > > startinfo.Redir ectStandardOutp ut = true;
    > > startinfo.Creat eNoWindow = true;
    > > process = System.Diagnost ics.Process.Sta rt(startinfo);
    > > stdoutreader = process.Standar dOutput;
    > > System.Text.Str ingBuilder stdoudtotal = new[/color][/color]
    System.Text.Str ingBuilder("");[color=blue][color=green]
    > > while((stdoutli ne=stdoutreader .ReadLine())!= null)
    > > {
    > > stdoudtotal.App end( "> " + stdoutline.ToSt ring() + "\n" );
    > > }
    > > stdoutreader.Cl ose();
    > > stdoutreader = null;
    > > if ( process.ExitCod e == 0 )
    > > {
    > > return stdoudtotal.ToS tring();
    > > }
    > > else
    > > {
    > > return stdoudtotal.ToS tring();
    > > }
    > > }
    > > catch(System.Ex ception exc)
    > > {
    > > return exc.ToString();
    > > }
    > > finally
    > > {
    > > if (process != null)
    > > {
    > > process.Close() ;
    > > }
    > > process = null;
    > > startinfo = null;
    > > }
    > > }
    > > }
    > >
    > > Regards
    > > Anders
    > >
    > >[/color]
    >
    >[/color]


    Comment

    Working...