To work with these examples you need to create a test folder in C: drive. Let's start with the copy the autoexec.bat file from C: to C:Trail. To do this you need the simple script:
Code:
<SCRIPT Language=vbscript>
<! -
Dim Drive, OggFile, origin, destination
source = "c: autoexec.bat"
target = "c: trail"
Set fso = CreateObject ("Scripting.FileSystemObject")
December OggFile fso.GetFile = (source)
OggFile.Copy destination, true
document.write "File" & & source "was
copied to "& target &". "
//-->
</SCRIPT>
We associate this script with a function called by the click of a button:
HTML Code:
<HTML>
<HEAD>
<TITLE> Exercise </ TITLE>
</ HEAD>
<BODY>
<SCRIPT Language=vbscript>
<! -
function copy ()
Dim Drive, OggFile, origin, destination
source = "c: autoexec.bat"
target = "c: trail"
Set fso = CreateObject ("Scripting.FileSystemObject")
December OggFile fso.GetFile = (source)
OggFile.Copy destination, true
msgbox "The file" & source & "has been copied to" & target & "."
end function
//-->
</SCRIPT>
<input type=button value=Copy>
</BODY>
</HTML>
Bookmarks