0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Forgive my lack of knowledge, I have zero programming eduction. Where exactly should I place that line?
Updated to answer you question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.