i need to run cmd.exe from a wwwroot\test folder... getting 800a0046

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jweiss
    New Member
    • Jun 2007
    • 1

    i need to run cmd.exe from a wwwroot\test folder... getting 800a0046

    I am trying to run cmd.exe so that I can ftp a file to a remote server. I've been doing this for a long time, but something broke. I did some windows updates last week??

    I am getting a 'permission denied' error at this line 48...

    48 Call oScript.Run ("C:\inetpub\ww wroot\test\cmd. exe /c " & strCMD & " > " & strTempFile, 0, True)


    I am stumbling with permissions here.
    Here is where my cmd.exe lives (i copied it from system32)
    C:\Inetpub\wwwr oot\test

    HELP


    Here is the rest of my code

    'On Error Resume Next
    Set oScript = Server.CreateOb ject("WSCRIPT.S HELL")
    Set oFileSys = Server.CreateOb ject("Scripting .FileSystemObje ct")
    Set objFSO = CreateObject("S cripting.FileSy stemObject")

    ' Build our ftp-commands file
    Set objTextFile = objFSO.CreateTe xtFile("C:\Inet pub\wwwroot\tes t\test.ftp")
    objTextFile.Wri teLine "lcd C:\Inetpub\wwwr oot\test\test.f tp"
    objTextFile.Wri teLine "open " & ftp_address
    objTextFile.Wri teLine ftp_username
    objTextFile.Wri teLine ftp_password

    ' Check to see if we need to issue a 'cd' command
    If ftp_remote_dire ctory <> "" Then
    objTextFile.Wri teLine "cd " & ftp_remote_dire ctory
    End If

    objTextFile.Wri teLine "prompt"
    objTextFile.Wri teLine "put " & ftp_files_to_pu t & " " & ftp_file_destin ation
    objTextFile.Wri teLine "bye"
    objTextFile.Clo se
    Set objTextFile = Nothing


    ' Use cmd.exe to run ftp.exe, parsing our newly created command file
    strCMD = "ftp.exe -s: C:\Inetpub\wwwr oot\test\test.f tp"
    strTempFile = "C:\Inetpub\www root\test" & "\" & oFileSys.GetTem pName( )

    ' Pipe output from cmd.exe to a temporary file (Not :| Steve)
    Call oScript.Run ("C:\inetpub\ww wroot\test\cmd. exe /c " & strCMD & " > " & strTempFile, 0, True)
    Set oFile = oFileSys.OpenTe xtFile (strTempFile, 1, False, 0)

    On Error Resume Next
    ' Grab output from temporary file
    strCommandResul t = Server.HTMLEnco de( oFile.ReadAll )
    oFile.Close


    ' Delete the temporary & ftp-command files
    'Call oFileSys.Delete File( strTempFile, True )
    'Call objFSO.DeleteFi le( Server.MapPath( "test.ftp") , True )
    Set oFileSys = Nothing
    Set objFSO = Nothing

    ' Print result of FTP session to screen
    Response.Write( Replace( strCommandResul t, vbCrLf, "<br>", 1, -1, 1) )
  • danp129
    Recognized Expert Contributor
    • Jul 2006
    • 323

    #2
    Try to use &#91;code] &#91;/code] tags.

    You should start by making sure all files you're executing (cmd.exe, ftp.exe) allow execute permissions and directories your temp files will be created in have modify permissions for the account logged into the site if using integrated authentication, or iuser_computern ame if not. Beware that there are hackers/viruses that attempt to execute cmd.exe from various locations on websites so make the subdirectory containing cmd.exe is a hard to guess name.

    Comment

    Working...