Problem of invoking a command line from ASP.NET 2.0?

Discussion in 'ASP .Net Security' started by Speech Lover, May 8, 2007.

  1. Speech Lover

    Speech Lover Guest

    Hi,

    First of all thanks for any response!
    I want to start a command line command from C# 2.0.
    Since .net 2.0 provides a way to specify a particular credential in
    ProcessStartInfo object to run the command line, I am able to impersonate a
    particular user to run this command.

    However, no matter how simple the command is, say invoking Notepad.exe, I
    always got the following error messages:



    System.ComponentModel.Win32Exception was unhandled
    Message="The parameter is incorrect"
    Source="System"
    ErrorCode=-2147467259
    NativeErrorCode=87
    StackTrace:
    at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo
    startInfo)
    at System.Diagnostics.Process.Start()
    at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
    at WindowsApplication1.Form1.InvokeDosCommand() in C:\Documents and
    Settings\vizhou\My Documents\Visual Studio 2005\Projects\WebSite1
    (2)\WindowsApplication1\Form1.cs:line 50
    at WindowsApplication1.Form1.button1_Click(Object sender, EventArgs
    e) in C:\Documents and Settings\vizhou\My Documents\Visual Studio
    2005\Projects\WebSite1 (2)\WindowsApplication1\Form1.cs:line 21
    at System.Windows.Forms.Control.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnClick(EventArgs e)
    at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
    at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons
    button, Int32 clicks)
    at System.Windows.Forms.Control.WndProc(Message& m)
    at System.Windows.Forms.ButtonBase.WndProc(Message& m)
    at System.Windows.Forms.Button.WndProc(Message& m)
    at
    System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
    m)
    at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
    Int32 msg, IntPtr wparam, IntPtr lparam)
    at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&
    msg)
    at
    System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32
    dwComponentID, Int32 reason, Int32 pvLoopData)
    at
    System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
    reason, ApplicationContext context)
    at
    System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
    ApplicationContext context)
    at System.Windows.Forms.Application.Run(Form mainForm)
    at WindowsApplication1.Program.Main() in C:\Documents and
    Settings\vizhou\My Documents\Visual Studio 2005\Projects\WebSite1
    (2)\WindowsApplication1\Program.cs:line 17
    at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
    args)
    at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
    assemblySecurity, String[] args)
    at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    at System.Threading.ExecutionContext.Run(ExecutionContext
    executionContext, ContextCallback callback, Object state)
    at System.Threading.ThreadHelper.ThreadStart()
    Speech Lover, May 8, 2007
    #1
    1. Advertising

  2. Speech Lover

    Speech Lover Guest

    Thank you very much for your response.

    Your tip is very helpful. I got it working by specifying a complete path to
    the application.

    In .Net 1.1 the FileName doesn't need to be a complete path as long as
    WorkingDirectory is specified.
    This is different in .Net 2.0.

    I really appreciate your sincere help!


    Speech Lover

    "MasterGaurav (www.edujini-labs.com)" <>
    wrote in message news:%...
    >> First of all thanks for any response!
    >> I want to start a command line command from C# 2.0.
    >> Since .net 2.0 provides a way to specify a particular credential in
    >> ProcessStartInfo object to run the command line, I am able to impersonate
    >> a particular user to run this command.
    >>
    >> However, no matter how simple the command is, say invoking Notepad.exe, I
    >> always got the following error messages:

    >
    > IMHO, you should not get a permission to start a process in ASP.Net
    > And even if you get it, are you using the complete path to Notepath.exe?
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish | www.mastergaurav.com
    > www.edujini-labs.com
    > http://eduzine.edujini-labs.com
    > -----------------------------------------
    >
    >
    Speech Lover, May 8, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Cowald
    Replies:
    4
    Views:
    1,028
    Tohid
    Oct 23, 2003
  2. Simon Harvey

    Invoking a command line .exe program

    Simon Harvey, Jul 29, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    4,229
    Eric Johannsen
    Jul 29, 2004
  3. Dave Neuendorf
    Replies:
    5
    Views:
    6,702
    Anthony Borla
    Feb 25, 2005
  4. Wade
    Replies:
    1
    Views:
    358
  5. Lucas Cowald

    RUN/execute a Command-Line command from an ASP page

    Lucas Cowald, Oct 22, 2003, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    219
    Genich
    Oct 22, 2003
Loading...

Share This Page