Uploading local files to server folders.

I am looking how to upload list of files what I provide with another scripts to the server folders. All paths and filenames I am able to provide for the new uploading code with my previous developed VBscripts. This attached cod is not good for me because WScript.Shell is not working with my system. Need to find completely another solution. Thank you guys!
'	 UPLOAD function for uploading the updated or added images to the server
Function FTPUpload(sSite, sUsername, sPassword, sLocalFile, sRemotePath)
Dim oFTPScriptFSO, oFTPScriptShell, sFTPScript, sFTPTemp, sFTPTempFile, sFTPResults, fFTPScript
  Const OpenAsDefault = -2
  Const FailIfNotExist = 0
  Const ForReading = 1
  Const ForWriting = 2
  Set oFTPScriptFSO = CreateObject("Scripting.FileSystemObject")
  Set oFTPScriptShell = CreateObject("WScript.Shell")
  sRemotePath = Trim(sRemotePath)
  sLocalFile = Trim(sLocalFile)
  '----------Path Checks---------
  'Here we willcheck the path, if it contains
  'spaces then we need to add quotes to ensure
  'it parses correctly.
  If InStr(sRemotePath, " ") > 0 Then
    If Left(sRemotePath, 1) <> """" And Right(sRemotePath, 1) <> """" Then
      sRemotePath = """" & sRemotePath & """"
    End If
  End If
  If InStr(sLocalFile, " ") > 0 Then
    If Left(sLocalFile, 1) <> """" And Right(sLocalFile, 1) <> """" Then
      sLocalFile = """" & sLocalFile & """"
    End If
  End If
  'Check to ensure that a remote path was
  'passed. If it's blank then pass a "\"
  If Len(sRemotePath) = 0 Then
    'Please note that no premptive checking of the
    'remote path is done. If it does not exist for some
    'reason. Unexpected results may occur.
    sRemotePath = "\"
  End If
  'Check the local path and file to ensure
  'that either the a file that exists was
  'passed or a wildcard was passed.
  If InStr(sLocalFile, "*") Then
    If InStr(sLocalFile, " ") Then
      FTPUpload = "Error: Wildcard uploads do not work if the path contains a " & _
      "space." & vbCRLF
      FTPUpload = FTPUpload & "This is a limitation of the Microsoft FTP client."
      Exit Function
    End If
  ElseIf Len(sLocalFile) = 0 Or Not oFTPScriptFSO.FileExists(sLocalFile) Then
    'nothing to upload
    FTPUpload = "Error: File Not Found."
    Exit Function
  End If
  '--------END Path Checks---------
  'build input file for ftp command
  sFTPScript = sFTPScript & "USER " & sUsername & vbCRLF
  sFTPScript = sFTPScript & sPassword & vbCRLF
  sFTPScript = sFTPScript & "cd " & sRemotePath & vbCRLF
  sFTPScript = sFTPScript & "binary" & vbCRLF
  sFTPScript = sFTPScript & "prompt n" & vbCRLF
  sFTPScript = sFTPScript & "put " & sLocalFile & vbCRLF
  sFTPScript = sFTPScript & "quit" & vbCRLF & "quit" & vbCRLF & "quit" & vbCRLF
  sFTPTemp = oFTPScriptShell.ExpandEnvironmentStrings("%TEMP%")
  sFTPTempFile = sFTPTemp & "\" & oFTPScriptFSO.GetTempName
  sFTPResults = sFTPTemp & "\" & oFTPScriptFSO.GetTempName
  'Write the input file for the ftp command
  'to a temporary file.
  Set fFTPScript = oFTPScriptFSO.CreateTextFile(sFTPTempFile, True)
  Set fFTPScript = Nothing  
  oFTPScriptShell.Run "%comspec% /c FTP -n -s:" & sFTPTempFile & " " & sSite & _
  " > " & sFTPResults
  Wscript.Sleep 1000
  'Check results of transfer.
  Set fFTPResults = oFTPScriptFSO.OpenTextFile(sFTPResults, ForReading, _
  FailIfNotExist, OpenAsDefault)
  sResults = fFTPResults.ReadAll
  oFTPScriptFSO.DeleteFile (sFTPResults)
  If InStr(sResults, "226 Transfer complete.") > 0 Then
    FTPUpload = True
  ElseIf InStr(sResults, "File not found") > 0 Then
    FTPUpload = "Error: File Not Found"
  ElseIf InStr(sResults, "cannot log in.") > 0 Then
    FTPUpload = "Error: Login Failed."
    FTPUpload = "Error: Unknown."
  End If
  Set oFTPScriptFSO = Nothing
  Set oFTPScriptShell = Nothing
End Function

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello vlad555,

What do you mean by Wscript.shell is not working?  If you are having issues with Wscript maybe it would be better to fix the issue rather than writing a script for a broken PC.  Any more details?


vlad555Author Commented:
Hallo dis1031,

Wscript.shell is not supported by IIS version 5.1 This script is not creating the file in TEMP folder.Also i can not use it as a VB Script and when I rename the extension to .aspx it also give me the error. Also in
http://www.dmxzone.com/ShowDetail.asp?NewsId=12143 they asking good money what i am unable to pay.

Thank you,
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

vlad555Author Commented:
Hallo gawai,

Sorry, I didn`t look down on your link. Thank you for the code i will try it and let you know how it works for me.

Thank you,
vlad555Author Commented:
Hallo dis1931,

No, i can not use this script: http://www.dmxzone.com/ShowDetail.asp?NewsId=12143
because have to buy it. Can someone help me to fix the existing inside my Code Snippet? The first step is to run this part:

Run in a new process:

Set objShell=Wscript.CreateObject("WScript.Shell")
objShell.Run "notepad.exe",3,True
wscript.echo "Now that notepad has closed you can read this"

 - would run and maximize Notepad but would not run the rest of the script until the process has ended.

If I get this to work, hopfully run all other too.

All the best,

Do you want the notepad to close automatically?


Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vlad555Author Commented:
Hi Gawai,

I need a time to explore all this solutions.  Please be patient and I will give you the answer.

vlad555Author Commented:
The last example fom mr. Gawai: www.motobit.com/help/scptutl/upload.asp is pretty, alot what can be got to learn but I can not use it here because this scripts need to be on server. In my case I need to upload files from client to server and have controls of server on client site to log in and provide source + destination paths.

I decided to return into the first code snippet in this question to solve the problem I have with WScript.Shell  for which I dont have support on my Internet Information Service Version 5.1. I try to call my snippet function and get the

Error Type:
/05/boss4web/UplTest.asp, line 94

Where line 94 is:   oFTPScriptShell.Run "%cmd% /c FTP -n -s:" & sFTPTempFile & " " & sSite & _
  " > " & sFTPResults

Question - Is my call:  

call FTPUpload("sha-lal-llaaa.com", "some-user", "password", "C:\my\web\som\local\folder\product_picture1.jpg", "som\remote\images\folderl\product_picture1.jpg")

is this call is made right? Why I have this error if its right?

Thank you everyone!
vlad555Author Commented:
Another test I perfomed is in the attached snippet. I uploaded this on my server and tryed to run it there to test shall I have same problem on server or not.  I got the next error:

Microsoft VBScript runtime error '800a01b6'

Object doesn't support this property or method: 'Echo'

/1111.asp, line 14

Error line 14  in snippet is this: WshShell.Echo "Hello World!" 'VBScript
Copy the snippet to the dremveawer or Visula Studio to see better my comments and code.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
'WScript object used to create objects
set WshShell = server.CreateObject("WScript.Shell")
'WScript object used to echo information
WshShell.Echo "Hello World!" 'VBScript
'WScript.Echo("Hello World!") 'JScript
'WScript object used to terminate scripts

Open in new window

wshshell.echo doesn't work in ASP you have to write that as

response.write "Hello World"
vlad555Author Commented:
The last link on a solution have alot of useful scripts but it will take few months to complete this way to implement it into my case.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.