Asp.net Vbscript Error
Please tell me where I have gone wrong in this script. I am getting this error.
Server Error in '/' Application.
Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Pleas开发者_Python百科e review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30002: Type 'ProcessStartInfo' is not defined.
Source Error:
Line 5: Public Shared Function ExecuteCommand(Command As String, Timeout As Integer) As Integer
Line 6: Dim ExitCode As Integer
*Line 7: Dim ProcessInfo As ProcessStartInfo*
Line 8: Dim Process As Process
Line 9:
Source File: C:\Inetpub\wwwroot\ServiceFileUploadRE.aspx Line: 7
The Script:
<%@ Page Language=VBScript %>
<script runat="server">
Public Shared Function ExecuteCommand(Command As String, Timeout As Integer) As Integer
Dim ExitCode As Integer
Dim ProcessInfo As ProcessStartInfo
Dim Process As Process
ProcessInfo = New ProcessStartInfo("cmd.exe", "/C " + Command)
ProcessInfo.CreateNoWindow = True
ProcessInfo.UseShellExecute = False
Process = Process.Start(ProcessInfo)
Process.WaitForExit(Timeout)
ExitCode = Process.ExitCode
Process.Close()
Return ExitCode
End Function
Protected Sub Button1_Click(ByVal sender As Object, _
ByVal e As System.EventArgs)
If FileUpload1.HasFile Then
Try
FileUpload1.SaveAs("C:\Inetpub\wwwroot\upload\" & _
FileUpload1.FileName)
Label1.Text = "File name: " & _
FileUpload1.PostedFile.FileName & "<br>" & _
"File Size: " & _
FileUpload1.PostedFile.ContentLength & " kb<br>" & _
"Content type: " & _
FileUpload1.PostedFile.ContentType
Catch ex As Exception
Label1.Text = "ERROR: " & ex.Message.ToString()
End Try
Else
Label1.Text = "You have not specified a file."
End If
End Sub
ExecuteCommand("REN C:\Document.rtf YES.rtf",100)
</script>
.......
Maybe place the line
<%@ Import Namespace = "System.Diagnostics" %>
directly after <% Page...
.
If that does not work, then check whether you are using .NET Framework 4.
精彩评论