There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot browser bsod computer crash css dell desktop driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware help please hijackthis hjt hjt log install internet internet explorer itunes javascript keyboard laptop log malware monitor network networking openoffice outlook outlook 2003 outlook express password popups problem router seo slow sound sp3 spyware startup trojan usb video virtumonde virus vista vundo windows windows xp winxp wireless youtube
DOS/PDA/Other
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > DOS/PDA/Other >
problem with a loop in a batch script


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
calacausi's Avatar
Junior Member with 1 posts.
 
Join Date: Apr 2008
24-Apr-2008, 04:14 AM #1
problem with a loop in a batch script
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>&nbsp;</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>&nbsp;</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
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 05:49 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.