Scripting.FileSystemObject with VBScript in HTML page

R

RaYlee

Hi,

I am a newbie to VBScript and I am working on a web page which requires to
save some data
into directory folder. So I searched the web and found some source codes to
do it, however,
it seems the codes are not working at all.

I guess it may be guarded by the IE browser to prevent the code from
execution.

Does any expert tell me whether I should use this way to create folder and
file in file system
via html page? If possible, must I set anythings in IE browser to allow this
operation?

The source code:

<FORM NAME="Form1">
<TABLE BORDER=0 width=100%>
<TR>
<TD ALIGN="left">Click <a href="javascript:framePrint('content');">HERE</a>
to print the following contents online.</TD>
<TD ALIGN="right"><INPUT TYPE="Button" NAME="Button1" VALUE="Batch Print">
<SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
MsgBox "Test Starts"
Dim objFSO, objFolder
Set objFSO = CreateObject("Scripting.FileSystemObject")
MsgBox "FSO Created"
If objFSO.FolderExists(strDirectory) Then
Set objFolder = objFSO.GetFolder(strDirectory)
Else
Set objFolder = objFSO.CreateFolder(strDirectory)
End If
MsgBox "Test Completed!"
</SCRIPT>
</TD>
</TR>
</TABLE>
</FORM>

Only "Test Starts" is shown and no "FsO Created" is displayed.

Thanks for your attention and help in advance,
Raymond



__________ Information from ESET NOD32 Antivirus, version of virus signature database 4323 (20090810) __________

The message was checked by ESET NOD32 Antivirus.

http://www.eset.com
 

My Computer

E

ekkehard.horner

RaYlee schrieb:

> Hi,
>
> I am a newbie to VBScript and I am working on a web page which requires to
> save some data
> into directory folder. So I searched the web and found some source codes to
> do it, however,
> it seems the codes are not working at all.
>
> I guess it may be guarded by the IE browser to prevent the code from
> execution.
>
> Does any expert tell me whether I should use this way to create folder and
> file in file system
> via html page? If possible, must I set anythings in IE browser to allow this
> operation?
>
> The source code:
>
> <FORM NAME="Form1">
> <TABLE BORDER=0 width=100%>
> <TR>
> <TD ALIGN="left">Click <a href="javascript:framePrint('content');">HERE</a>
> to print the following contents online.</TD>
> <TD ALIGN="right"><INPUT TYPE="Button" NAME="Button1" VALUE="Batch Print">
> <SCRIPT FOR="Button1" EVENT="onClick" LANGUAGE="VBScript">
> MsgBox "Test Starts"
> Dim objFSO, objFolder
> Set objFSO = CreateObject("Scripting.FileSystemObject")
> MsgBox "FSO Created"
> If objFSO.FolderExists(strDirectory) Then
> Set objFolder = objFSO.GetFolder(strDirectory)
> Else
> Set objFolder = objFSO.CreateFolder(strDirectory)
> End If
> MsgBox "Test Completed!"
> </SCRIPT>
> </TD>
> </TR>
> </TABLE>
> </FORM>
>
> Only "Test Starts" is shown and no "FsO Created" is displayed.
>
> Thanks for your attention and help in advance,
> Raymond
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 4323 (20090810) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
use a .hta file instead of a .thml file. Avoid to lower the security level
of IE.
 

My Computer

M

mr_unreliable

RaYlee wrote:

> I am a newbie to VBScript and I am working on a web page which requires to
> save some data into directory folder. So I searched the web and found some
> source codes to do it, however, it seems the codes are not working at all.
>
> I guess it may be guarded by the IE browser to prevent the code from
> execution.
>
hi RaYlee, did you understand Ekkehardt's response? It was timely,
but a little brief.

I think what he intended to say was that you couldn't use the "fso"
object in browser (IE) code. That is because with fso you can change
and/or delete stuff on somebody's system. And if that were ever
allowed then any web page could potentially cause is serious damage...

What he suggested was to use an "HTA" application -- which is a web
page with an "HTA" extension instead of an "HTM" extension (plus an
hta tag). An HTA miniapp is not subject to the same security
restrictions as an HTM page.

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
 

My Computer

T

Tim Williams

Should add that HTA is *not* a viable solution unless this is an intranet
project. You'd have to be crazy to open an HTA from an internet location.
The usual way to do this would be to have the server send the data with the
appropriate headers, and have the end-user decide what to do with it
(open/save).

Tim

"mr_unreliable" <[email protected]> wrote in message
news:[email protected]

> RaYlee wrote:

>> I am a newbie to VBScript and I am working on a web page which requires
>> to save some data into directory folder. So I searched the web and found
>> some
>> source codes to do it, however, it seems the codes are not working at
>> all.
>>
>> I guess it may be guarded by the IE browser to prevent the code from
>> execution.
>>
>
> hi RaYlee, did you understand Ekkehardt's response? It was timely,
> but a little brief.
>
> I think what he intended to say was that you couldn't use the "fso"
> object in browser (IE) code. That is because with fso you can change
> and/or delete stuff on somebody's system. And if that were ever
> allowed then any web page could potentially cause is serious damage...
>
> What he suggested was to use an "HTA" application -- which is a web
> page with an "HTA" extension instead of an "HTM" extension (plus an
> hta tag). An HTA miniapp is not subject to the same security
> restrictions as an HTM page.
>
> cheers, jw
> ____________________________________________________________
>
> You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
> the answers will be applicable to the questions)
>
 

My Computer

M

mayayana


> Should add that HTA is *not* a viable solution unless this is an intranet
> project. You'd have to be crazy to open an HTA from an internet location.
> The usual way to do this would be to have the server send the data with
the

> appropriate headers, and have the end-user decide what to do with it
> (open/save).
It's designed not to work remotely at all. That's
the one restriction. A person who clicks a link
should not even be given a choice about opening
the page. They just get a "where do you want to
put it?" window. In fact, I sometimes get that even
when it's local. I don't remember why. Maybe it was
a case where I ran the HTA through other code? I'm
not sure.
 

My Computer

M

mr_unreliable

RaYlee wrote:

> I am a newbie to VBScript and I am working on a web page which requires to
> save some data into directory folder.
hi RaYlee,

Here is another approach you might consider. Use an "installer".

There are all sorts of installers out there, many are free.
Most likely you will already have microsoft's own installer
(called "msi") installed on your system. Microsoft uses its
installer to upgrade your system.

An installer will do almost anything you can imagine.
For example, you can create sub-directories (er, folders)
and stuff data into those newly-created folders.

The usual webpage treatment for installer downloads would
be to post some instructions to the user, such as: "if you
want me to install this new data on your system, download
this file to your desktop and click on it... ".

cheers, jw
____________________________________________________________

You got questions? WE GOT ANSWERS!!! ..(but, no guarantee
the answers will be applicable to the questions)
 

My Computer

Top