【问题标题】:Asp.net Vbscript ErrorAsp.net Vbscript 错误
【发布时间】:2011-07-26 16:44:44
【问题描述】:

请告诉我这个脚本哪里出了问题。我收到此错误。

“/”应用程序中的服务器错误。

编译错误 说明:在编译服务此请求所需的资源期间发生错误。请查看以下特定错误详细信息并适当修改您的源代码。

编译器错误消息:BC30002:未定义类型“ProcessStartInfo”。

来源错误:

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:  

源文件:C:\Inetpub\wwwroot\ServiceFileUploadRE.aspx 行:7

脚本:

  <%@ 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>
.......

【问题讨论】:

    标签: asp.net vbscript


    【解决方案1】:

    也许放线

    <%@ Import Namespace = "System.Diagnostics" %>
    

    直接在&lt;% Page...之后。

    如果这不起作用,请检查您是否使用的是 .NET Framework 4。

    【讨论】:

    • 原谅我的知识匮乏,我的编程教育为零。我应该把那条线放在哪里?
    • 已更新以回答您的问题。
    猜你喜欢
    • 1970-01-01
    • 2011-07-23
    • 1970-01-01
    • 1970-01-01
    • 2011-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    相关资源
    最近更新 更多