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

S

Speech Lover

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()
 
S

Speech Lover

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
 

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

Members online

Forum statistics

Threads
473,754
Messages
2,569,522
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top