Groups | Blog | Home
all groups > asp.net security > may 2007 >

asp.net security : Problem of invoking a command line from ASP.NET 2.0?


Speech Lover
5/7/2007 7:08:06 PM
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
5/8/2007 11:35:26 AM
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)" <gaurav.vaish.nospam@nospam.gmail.com>
[quoted text, click to view]

MasterGaurav (www.edujini-labs.com)
5/8/2007 11:17:27 PM
[quoted text, click to view]

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
-----------------------------------------

AddThis Social Bookmark Button