hi all,
I should write a batch script to copy some files from one to another location.
Searching on the net I found an example and rearrange it. It seems to work, but... only once! The script only works the first time it's used; then, it looks like it isnt able to reload the html code.
How can I modify it to execute the copy operation more than one time?
Please help me. this is the script code
@echo off
title Copy files
echo select one file from the dropdown...
If not exist %0 goto ERROR
type %0 | find " " | find /v " " | find /v "Not Me!" > %TEMP%\UserIn.htm
type %0 | find " " | find /v " " | find /v "Not Me!" > %TEMP%\UserIn.vbs
start /w wscript.exe %TEMP%\UserIn.vbs
call %TEMP%\UserIn.bat
copy %USERNAME% %PASSWORD%
del %TEMP%\UserIn.vbs
del %TEMP%\UserIn.htm
del %TEMP%\UserIn.bat
goto DONE
:ERROR
cls
echo %0 put path-name and file name
goto DONE
:HTML
<html><title>Copy files</title>
<body bgcolor='#B7E8FF'>
<form>
<table width="100%" >
<tr><td align="left"><img src="c:\Logo.gif" width="60" height="60"></td>
<td align="left"><b><font size=4>COPY FILES</font></b></td></tr>
</table>
<br>
<table width="50%" align="center">
<tr><td align="left" colspan=2>Select file to copy:</td></tr>
<tr><td align="left" colspan=2><select name=username tabindex=1 onchange='b_submit.value="Copy"'></select></td></tr>
<tr><td> </td></tr>
<tr><td align="left" colspan=2>Copy to directory:</td></tr>
<tr><td align="left" colspan=2><input type=text name=password readonly value="C:\DESTFOLDER\" size=27></td></tr>
<tr><td> </td></tr>
<tr><td align="center" colspan=2><input type=button
language=vbscript id=b_submit name=b_submit
value=Copia onclick='b_submit.value="FILE COPIED"'></td></tr>
</table>
</form></body></html>
:VBS
Set fs = CreateObject("Scripting.FileSystemObject")
strFile = fs.GetAbsolutePathName(fs.BuildPath(fs.GetSpecialFolder(2), "UserIn.htm"))
Set web = CreateObject("InternetExplorer.Application")
web.Offline = True
web.AddressBar = False
web.Left=200
web.Top=100
web.Height = 350
web.Width = 500
web.Resizable=False
web.MenuBar = False
web.StatusBar = False
web.Silent = True
web.ToolBar = False
web.Navigate strFile
Do While web.Busy
Loop
On Error Resume Next
Set doc = Nothing
Do Until Not doc Is Nothing
Set doc = web.Document
Loop
srcfld="sourcefolder"
set folder = fs.GetFolder(srcfld)
k=0
For Each file in folder.Files
strFile = file.name
doc.Forms(0).elements("username").options.length=k+1
doc.Forms(0).elements("username").options(k).text=unescape(strFile)
doc.Forms(0).elements("username").options(k).value=unescape(strFile)
k=k+1
Next
web.Visible = True
Err.Clear
Do Until doc.Forms(0).elements("b_submit").Value <> "Copy"
Wscript.Sleep 100
If Err.Number <> 0 Then Exit Do
Loop
strFile = fs.GetAbsolutePathName(fs.BuildPath(fs.GetSpecialFolder(2), "UserIn.bat"))
Set ts = fs.OpenTextFile(strFile, 2, True)
ts.WriteLine "SET USERNAME=" & Cartella & "\" & doc.Forms(0).elements("username").Value
ts.WriteLine "SET PASSWORD=" & doc.Forms(0).elements("password").Value
ts.Close
'web.Quit

ONE