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) )
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) )
Comment