Re: Using the Shell function in a web application
From: Steve C. Orr [MVP, MCSD] (Steve_at_Orr.net)
Date: 03/09/04
- Next message: Colin Basterfield: "Re: Default.aspx - newbie Q`"
- Previous message: Steve C. Orr [MVP, MCSD]: "Re: Get the current HttpResponse"
- In reply to: Eric Caron: "Using the Shell function in a web application"
- Next in thread: Steve C. Orr [MVP, MCSD]: "Re: Using the Shell function in a web application"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 8 Mar 2004 16:10:20 -0800
Yes, it's probably a permissions issue.
You'll likely want to try using impersonation so you're running under a user
account that has the necessary permissions. (Try setting it to use your
username & pw for initial testing purposes.)
Here's more info:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaspnetimpersonation.asp
Also, you might try using the process object since it's a bit more robust
than shell. Here's an example:
Dim proc As System.Diagnostics.Process = New System.Diagnostics.Process()
proc.StartInfo.FileName = "C:\test.exe"
proc.StartInfo.WorkingDirectory = "C:\"
proc.StartInfo.Arguments = strMyArguments
proc.Start()
-- I hope this helps, Steve C. Orr, MCSD, MVP http://Steve.Orr.net "Eric Caron" <ecaron@nospam.quebecaffaires.com> wrote in message news:uRnzATUBEHA.2768@tk2msftngp13.phx.gbl... > Hi all, > > I'm trying to automate some tasks on a server in our intranet by using a web > application. I already have a batch script that registers a DLL passed as a > parameter on the command line. I'd like to be able to first copy a file > from a shared location to the root of the c:\ drive, then call my batch file > with the file as a parameter. I found the Shell function that seemed to do > what I want and did a quick and dirty web form with a textbox and a button > with the following code on the on_click handler of the button: > > strCommandLine = "copy E:\Data\" & Me.txtCommand.Text & " c:\" > Response.Write("<p>" & strCommandLine & "</p>" & vbCrLf) > Shell("copy E:\Data\" & Me.txtCommand.Text & " c:\", AppWinStyle.Hide, True) > strCommandLine = "update.bat " & Me.txtCommand.Text > Response.Write("<p>" & strCommandLine & "</p>" & vbCrLf) > Shell("update.bat " & Me.txtCommand.Text) > > However, I get the following error when the Shell command is executed: > > File not found. > Description: An unhandled exception occurred during the execution of the > current web request. Please review the stack trace for more information > about the error and where it originated in the code. > > Exception Details: System.IO.FileNotFoundException: File not found. > > I'm sure of the path and the file is there. I'm wondering if it's a > permission problem and the error message is misleading me. > > Any example of a similar task? > >
- Next message: Colin Basterfield: "Re: Default.aspx - newbie Q`"
- Previous message: Steve C. Orr [MVP, MCSD]: "Re: Get the current HttpResponse"
- In reply to: Eric Caron: "Using the Shell function in a web application"
- Next in thread: Steve C. Orr [MVP, MCSD]: "Re: Using the Shell function in a web application"
- Messages sorted by: [ date ] [ thread ]