By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

Script w/ FileSystemObject, error creating object

P: n/a
I keep seeing that you can use the FileSystemObject in either VB script, or
Javascript on an aspx page.

I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object', 'Scripting',
'Scripting.FileSystemObject', and a few others

However, when I try to create the fso object I keep receiving an error.

'ActiveX component can't create object: 'Scripting.FileSystemObject'

What am I missing?
All I am trying to do is delete a file on the onbeforeunload event.
I have spent the better part of two days on this.
All help greatly appreciated.

Nov 19 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a
Are you trying to delete a file on the user's system? If so, the browser's
security is going to make this difficult if not impossible.

Apart from that, it looks like you are trying to mix .NET server-side code
with client-side Javascript in a way that can't be done.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
I keep seeing that you can use the FileSystemObject in either VB script,
or
Javascript on an aspx page.

I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object', 'Scripting',
'Scripting.FileSystemObject', and a few others

However, when I try to create the fso object I keep receiving an error.

'ActiveX component can't create object: 'Scripting.FileSystemObject'

What am I missing?
All I am trying to do is delete a file on the onbeforeunload event.
I have spent the better part of two days on this.
All help greatly appreciated.


Nov 19 '05 #2

P: n/a
I am trying to delete the file off of the server or another known
machine/path on the network. I am using a control that requires an XML file
to load. I don't want people stepping on each other so I generate a file
name with a random number and want to delete the file when the aspx page
unloads.
I cannot use the vb unload event, it occurs if the page is refreshed.
Possibly I could use the 'Disposed' event, but not sure how to trigger it.

I concur about mixing server/client code but I keep seeing threads that
indicate you can use the FileSystemObject in client script (javascript or
vbscript).

Frustrating.

"Ken Cox [Microsoft MVP]" wrote:
Are you trying to delete a file on the user's system? If so, the browser's
security is going to make this difficult if not impossible.

Apart from that, it looks like you are trying to mix .NET server-side code
with client-side Javascript in a way that can't be done.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
I keep seeing that you can use the FileSystemObject in either VB script,
or
Javascript on an aspx page.

I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object', 'Scripting',
'Scripting.FileSystemObject', and a few others

However, when I try to create the fso object I keep receiving an error.

'ActiveX component can't create object: 'Scripting.FileSystemObject'

What am I missing?
All I am trying to do is delete a file on the onbeforeunload event.
I have spent the better part of two days on this.
All help greatly appreciated.


Nov 19 '05 #3

P: n/a
Hi kermit,

Remove the reference to scrrun.dll. Remove the import statements. Remove all
code that attempts to use VBScript. And use the classes of the CLR to do
your work, specifically, the System.IO namespace for managing file and
directories.

ASP.Net has very little in common with ASP, other than the fact that they
both do similar types of work in the same environment. ASP.Net is Managed
code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
they are NOT compatible. You can use Interop to emulate compatibility, but
only as a last resort. It is NOT a good idea as a rule, and can
unnecessarily complicate your app and make it much harder for you to manage.

If you're uncomfortable with the ASP.Net programming paradigm, you might
want to stick with ASP for now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
I keep seeing that you can use the FileSystemObject in either VB script,
or
Javascript on an aspx page.

I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object', 'Scripting',
'Scripting.FileSystemObject', and a few others

However, when I try to create the fso object I keep receiving an error.

'ActiveX component can't create object: 'Scripting.FileSystemObject'

What am I missing?
All I am trying to do is delete a file on the onbeforeunload event.
I have spent the better part of two days on this.
All help greatly appreciated.

Nov 19 '05 #4

P: n/a
For deleting a file on the server, you should use one of the .NET classes
(File Class) rather than the FileSystemObject which is COM technology:

http://msdn.microsoft.com/library/en...asp?frame=true

You'll have a problem tracking the browser's unload event because that's a
client-side event. If the person types in a new URL, you'll be in trouble.

You might be better off to use the server-side Session_End event in the
global.asax file.

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
End Sub

However, that would leave the file hanging around for the length of the
Session timeout which is 20 minutes by default. It would be faster if you
could get people to click a logout button on which you would call
Session.Abandon.
Ken
Microsoft MVP [ASP.NET]
"kermit" <ke****@discussions.microsoft.com> wrote in message
news:6B**********************************@microsof t.com...
I am trying to delete the file off of the server or another known
machine/path on the network. I am using a control that requires an XML
file
to load. I don't want people stepping on each other so I generate a file
name with a random number and want to delete the file when the aspx page
unloads.
I cannot use the vb unload event, it occurs if the page is refreshed.
Possibly I could use the 'Disposed' event, but not sure how to trigger it.

I concur about mixing server/client code but I keep seeing threads that
indicate you can use the FileSystemObject in client script (javascript or
vbscript).

Frustrating.

"Ken Cox [Microsoft MVP]" wrote:
Are you trying to delete a file on the user's system? If so, the
browser's
security is going to make this difficult if not impossible.

Apart from that, it looks like you are trying to mix .NET server-side
code
with client-side Javascript in a way that can't be done.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
>I keep seeing that you can use the FileSystemObject in either VB
>script,
>or
> Javascript on an aspx page.
>
> I added a refrence to the scrrun.dll
> I added importing namespaces for 'System.Object', 'Scripting',
> 'Scripting.FileSystemObject', and a few others
>
> However, when I try to create the fso object I keep receiving an
> error.
>
> 'ActiveX component can't create object: 'Scripting.FileSystemObject'
>
> What am I missing?
> All I am trying to do is delete a file on the onbeforeunload event.
> I have spent the better part of two days on this.
> All help greatly appreciated.
>
>
>



Nov 19 '05 #5

P: n/a
I need to get comfortable with it. 90% of the time, plus, I'm OK. Then I
get tangled up in something like this.

OK, I got rid of scrrun.dll and am back to where I started, trying to use
the System.IO File.Delete(sfilename).

If I put the following in the <BODY> tag, it works, but at the wrong time
and only once.
<BODY onbeforeunload="<% File.Delete(hdnXMLfile.value) %>" ......

I tried putting an "if hdnUnload.value=True then .....

Again, since Server code only runs at render time on an aspx page, that did
not work at page unload.

How would you do this? I would really like to not leave the files until
Session_End.

"Kevin Spencer" wrote:
Hi kermit,

Remove the reference to scrrun.dll. Remove the import statements. Remove all
code that attempts to use VBScript. And use the classes of the CLR to do
your work, specifically, the System.IO namespace for managing file and
directories.

ASP.Net has very little in common with ASP, other than the fact that they
both do similar types of work in the same environment. ASP.Net is Managed
code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
they are NOT compatible. You can use Interop to emulate compatibility, but
only as a last resort. It is NOT a good idea as a rule, and can
unnecessarily complicate your app and make it much harder for you to manage.

If you're uncomfortable with the ASP.Net programming paradigm, you might
want to stick with ASP for now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
I keep seeing that you can use the FileSystemObject in either VB script,
or
Javascript on an aspx page.

I added a refrence to the scrrun.dll
I added importing namespaces for 'System.Object', 'Scripting',
'Scripting.FileSystemObject', and a few others

However, when I try to create the fso object I keep receiving an error.

'ActiveX component can't create object: 'Scripting.FileSystemObject'

What am I missing?
All I am trying to do is delete a file on the onbeforeunload event.
I have spent the better part of two days on this.
All help greatly appreciated.


Nov 19 '05 #6

P: n/a
Hi kermit,

Well, you're still trying to do OOP in a procedural fashion, and that's
going to continue to bite you as you go.

First, the <body> tag has nothing to do with the server-side programming. It
is there as part of the client-side HTML document. The "onbeforeunload"
event is, again, a client-side event, and doesn't happen or even have
anything to do with the server.

I'm going to do a little guesswork here, and guess that you have a file on
the server that was created sometime during the lifetime of the page in
question. Apparently, you want to delete the file when the doument is
navigated away from, the user Session ends, or the browser is closed. In any
case, the best bet is (probably) to use the Session_End server-side event to
do your file cleanup. IOW, this would not be any part of the page's
server-side code, but would be part of the Session_End event handler in your
global.asax class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I need to get comfortable with it. 90% of the time, plus, I'm OK. Then I
get tangled up in something like this.

OK, I got rid of scrrun.dll and am back to where I started, trying to use
the System.IO File.Delete(sfilename).

If I put the following in the <BODY> tag, it works, but at the wrong time
and only once.
<BODY onbeforeunload="<% File.Delete(hdnXMLfile.value) %>" ......

I tried putting an "if hdnUnload.value=True then .....

Again, since Server code only runs at render time on an aspx page, that
did
not work at page unload.

How would you do this? I would really like to not leave the files until
Session_End.

"Kevin Spencer" wrote:
Hi kermit,

Remove the reference to scrrun.dll. Remove the import statements. Remove
all
code that attempts to use VBScript. And use the classes of the CLR to do
your work, specifically, the System.IO namespace for managing file and
directories.

ASP.Net has very little in common with ASP, other than the fact that they
both do similar types of work in the same environment. ASP.Net is Managed
code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
they are NOT compatible. You can use Interop to emulate compatibility,
but
only as a last resort. It is NOT a good idea as a rule, and can
unnecessarily complicate your app and make it much harder for you to
manage.

If you're uncomfortable with the ASP.Net programming paradigm, you might
want to stick with ASP for now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
>I keep seeing that you can use the FileSystemObject in either VB
>script,
>or
> Javascript on an aspx page.
>
> I added a refrence to the scrrun.dll
> I added importing namespaces for 'System.Object', 'Scripting',
> 'Scripting.FileSystemObject', and a few others
>
> However, when I try to create the fso object I keep receiving an
> error.
>
> 'ActiveX component can't create object: 'Scripting.FileSystemObject'
>
> What am I missing?
> All I am trying to do is delete a file on the onbeforeunload event.
> I have spent the better part of two days on this.
> All help greatly appreciated.
>
>
>


Nov 19 '05 #7

P: n/a
Yes, I realize that all HTML tags are client side. I would assume for
correct object orented coding the web page should be 'controlled' by the
server. But it seems that there is often a need to do some clean up
when a browser window is closed (not the session or app, just a window
used by the application) and since it is not possible to ensure the user
always uses a 'Close' button, I am confused as to how to notify, or how
the server is to know, that the window has been closed - do cleanup.
I have given up and did use the session_end event. But it does not
seem to always trigger, esp. if the user closes the app with other than
the logout button, i.e. maybe browses to an entirely different place.
Your assumptions on what I am trying to do is correct. When the page
opens I create a file on the server (XML) and want to remove it when I am
done with it.
It has to last long enough for the page to complete loading all
controls.
I write the file to a dir on the server (or other network machine,
this is an intranet app). I cannot use a data island to pop. the control.
I guess I will write a app to run on a timer and delete files older than
x on regular basis.
XML is so heavly used, shopping carts, etc. I assume many (most) are
creating files, not data islands, what do people do to remove xml files no
longer needed?
Thank you for your assistance. My issue is complete. But if you have
any comments to add I would love to hear them.

"Kevin Spencer" wrote:
Hi kermit,

Well, you're still trying to do OOP in a procedural fashion, and that's
going to continue to bite you as you go.

First, the <body> tag has nothing to do with the server-side programming. It
is there as part of the client-side HTML document. The "onbeforeunload"
event is, again, a client-side event, and doesn't happen or even have
anything to do with the server.

I'm going to do a little guesswork here, and guess that you have a file on
the server that was created sometime during the lifetime of the page in
question. Apparently, you want to delete the file when the doument is
navigated away from, the user Session ends, or the browser is closed. In any
case, the best bet is (probably) to use the Session_End server-side event to
do your file cleanup. IOW, this would not be any part of the page's
server-side code, but would be part of the Session_End event handler in your
global.asax class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I need to get comfortable with it. 90% of the time, plus, I'm OK. Then I
get tangled up in something like this.

OK, I got rid of scrrun.dll and am back to where I started, trying to use
the System.IO File.Delete(sfilename).

If I put the following in the <BODY> tag, it works, but at the wrong time
and only once.
<BODY onbeforeunload="<% File.Delete(hdnXMLfile.value) %>" ......

I tried putting an "if hdnUnload.value=True then .....

Again, since Server code only runs at render time on an aspx page, that
did
not work at page unload.

How would you do this? I would really like to not leave the files until
Session_End.

"Kevin Spencer" wrote:
Hi kermit,

Remove the reference to scrrun.dll. Remove the import statements. Remove
all
code that attempts to use VBScript. And use the classes of the CLR to do
your work, specifically, the System.IO namespace for managing file and
directories.

ASP.Net has very little in common with ASP, other than the fact that they
both do similar types of work in the same environment. ASP.Net is Managed
code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
they are NOT compatible. You can use Interop to emulate compatibility,
but
only as a last resort. It is NOT a good idea as a rule, and can
unnecessarily complicate your app and make it much harder for you to
manage.

If you're uncomfortable with the ASP.Net programming paradigm, you might
want to stick with ASP for now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
>I keep seeing that you can use the FileSystemObject in either VB
>script,
>or
> Javascript on an aspx page.
>
> I added a refrence to the scrrun.dll
> I added importing namespaces for 'System.Object', 'Scripting',
> 'Scripting.FileSystemObject', and a few others
>
> However, when I try to create the fso object I keep receiving an
> error.
>
> 'ActiveX component can't create object: 'Scripting.FileSystemObject'
>
> What am I missing?
> All I am trying to do is delete a file on the onbeforeunload event.
> I have spent the better part of two days on this.
> All help greatly appreciated.
>
>
>


Nov 19 '05 #8

P: n/a
Yes, I realize that all HTML tags are client side. I would assume for
correct object orented coding the web page should be 'controlled' by the
server. But it seems that there is often a need to do some clean up
when a browser window is closed (not the session or app, just a window
used by the application) and since it is not possible to ensure the user
always uses a 'Close' button, I am confused as to how to notify, or how
the server is to know, that the window has been closed - do cleanup.
I have given up and did use the session_end event. But it does not
seem to always trigger, esp. if the user closes the app with other than
the logout button, i.e. maybe browses to an entirely different place.
Your assumptions on what I am trying to do is correct. When the page
opens I create a file on the server (XML) and want to remove it when I am
done with it.
It has to last long enough for the page to complete loading all
controls.
I write the file to a dir on the server (or other network machine,
this is an intranet app). I cannot use a data island to pop. the control.
I guess I will write a app to run on a timer and delete files older than
x on regular basis.
XML is so heavly used, shopping carts, etc. I assume many (most) are
creating files, not data islands, what do people do to remove xml files no
longer needed?
Thank you for your assistance. My issue is complete. But if you have
any comments to add I would love to hear them.

"Kevin Spencer" wrote:
Hi kermit,

Well, you're still trying to do OOP in a procedural fashion, and that's
going to continue to bite you as you go.

First, the <body> tag has nothing to do with the server-side programming. It
is there as part of the client-side HTML document. The "onbeforeunload"
event is, again, a client-side event, and doesn't happen or even have
anything to do with the server.

I'm going to do a little guesswork here, and guess that you have a file on
the server that was created sometime during the lifetime of the page in
question. Apparently, you want to delete the file when the doument is
navigated away from, the user Session ends, or the browser is closed. In any
case, the best bet is (probably) to use the Session_End server-side event to
do your file cleanup. IOW, this would not be any part of the page's
server-side code, but would be part of the Session_End event handler in your
global.asax class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I need to get comfortable with it. 90% of the time, plus, I'm OK. Then I
get tangled up in something like this.

OK, I got rid of scrrun.dll and am back to where I started, trying to use
the System.IO File.Delete(sfilename).

If I put the following in the <BODY> tag, it works, but at the wrong time
and only once.
<BODY onbeforeunload="<% File.Delete(hdnXMLfile.value) %>" ......

I tried putting an "if hdnUnload.value=True then .....

Again, since Server code only runs at render time on an aspx page, that
did
not work at page unload.

How would you do this? I would really like to not leave the files until
Session_End.

"Kevin Spencer" wrote:
Hi kermit,

Remove the reference to scrrun.dll. Remove the import statements. Remove
all
code that attempts to use VBScript. And use the classes of the CLR to do
your work, specifically, the System.IO namespace for managing file and
directories.

ASP.Net has very little in common with ASP, other than the fact that they
both do similar types of work in the same environment. ASP.Net is Managed
code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
they are NOT compatible. You can use Interop to emulate compatibility,
but
only as a last resort. It is NOT a good idea as a rule, and can
unnecessarily complicate your app and make it much harder for you to
manage.

If you're uncomfortable with the ASP.Net programming paradigm, you might
want to stick with ASP for now.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:47**********************************@microsof t.com...
>I keep seeing that you can use the FileSystemObject in either VB
>script,
>or
> Javascript on an aspx page.
>
> I added a refrence to the scrrun.dll
> I added importing namespaces for 'System.Object', 'Scripting',
> 'Scripting.FileSystemObject', and a few others
>
> However, when I try to create the fso object I keep receiving an
> error.
>
> 'ActiveX component can't create object: 'Scripting.FileSystemObject'
>
> What am I missing?
> All I am trying to do is delete a file on the onbeforeunload event.
> I have spent the better part of two days on this.
> All help greatly appreciated.
>
>
>


Nov 19 '05 #9

P: n/a
For any interested, I found a better work-a-round.
I used the client <BODY onunload...
to set the page location to a different aspx page (cleanup.aspx)
I used the server side on_load event to clean up (delete) my unwanted files.
Works rather or not the user clicks the 'Close window button' or just closes
the window.

"kermit" wrote:
Yes, I realize that all HTML tags are client side. I would assume for
correct object orented coding the web page should be 'controlled' by the
server. But it seems that there is often a need to do some clean up
when a browser window is closed (not the session or app, just a window
used by the application) and since it is not possible to ensure the user
always uses a 'Close' button, I am confused as to how to notify, or how
the server is to know, that the window has been closed - do cleanup.
I have given up and did use the session_end event. But it does not
seem to always trigger, esp. if the user closes the app with other than
the logout button, i.e. maybe browses to an entirely different place.
Your assumptions on what I am trying to do is correct. When the page
opens I create a file on the server (XML) and want to remove it when I am
done with it.
It has to last long enough for the page to complete loading all
controls.
I write the file to a dir on the server (or other network machine,
this is an intranet app). I cannot use a data island to pop. the control.
I guess I will write a app to run on a timer and delete files older than
x on regular basis.
XML is so heavly used, shopping carts, etc. I assume many (most) are
creating files, not data islands, what do people do to remove xml files no
longer needed?
Thank you for your assistance. My issue is complete. But if you have
any comments to add I would love to hear them.

"Kevin Spencer" wrote:
Hi kermit,

Well, you're still trying to do OOP in a procedural fashion, and that's
going to continue to bite you as you go.

First, the <body> tag has nothing to do with the server-side programming. It
is there as part of the client-side HTML document. The "onbeforeunload"
event is, again, a client-side event, and doesn't happen or even have
anything to do with the server.

I'm going to do a little guesswork here, and guess that you have a file on
the server that was created sometime during the lifetime of the page in
question. Apparently, you want to delete the file when the doument is
navigated away from, the user Session ends, or the browser is closed. In any
case, the best bet is (probably) to use the Session_End server-side event to
do your file cleanup. IOW, this would not be any part of the page's
server-side code, but would be part of the Session_End event handler in your
global.asax class.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"kermit" <ke****@discussions.microsoft.com> wrote in message
news:55**********************************@microsof t.com...
I need to get comfortable with it. 90% of the time, plus, I'm OK. Then I
get tangled up in something like this.

OK, I got rid of scrrun.dll and am back to where I started, trying to use
the System.IO File.Delete(sfilename).

If I put the following in the <BODY> tag, it works, but at the wrong time
and only once.
<BODY onbeforeunload="<% File.Delete(hdnXMLfile.value) %>" ......

I tried putting an "if hdnUnload.value=True then .....

Again, since Server code only runs at render time on an aspx page, that
did
not work at page unload.

How would you do this? I would really like to not leave the files until
Session_End.

"Kevin Spencer" wrote:

> Hi kermit,
>
> Remove the reference to scrrun.dll. Remove the import statements. Remove
> all
> code that attempts to use VBScript. And use the classes of the CLR to do
> your work, specifically, the System.IO namespace for managing file and
> directories.
>
> ASP.Net has very little in common with ASP, other than the fact that they
> both do similar types of work in the same environment. ASP.Net is Managed
> code. VBScript is not. ASP.Net is object-oriented. ASP is procedural. And
> they are NOT compatible. You can use Interop to emulate compatibility,
> but
> only as a last resort. It is NOT a good idea as a rule, and can
> unnecessarily complicate your app and make it much harder for you to
> manage.
>
> If you're uncomfortable with the ASP.Net programming paradigm, you might
> want to stick with ASP for now.
>
> --
> HTH,
>
> Kevin Spencer
> Microsoft MVP
> ..Net Developer
> What You Seek Is What You Get.
>
> "kermit" <ke****@discussions.microsoft.com> wrote in message
> news:47**********************************@microsof t.com...
> >I keep seeing that you can use the FileSystemObject in either VB
> >script,
> >or
> > Javascript on an aspx page.
> >
> > I added a refrence to the scrrun.dll
> > I added importing namespaces for 'System.Object', 'Scripting',
> > 'Scripting.FileSystemObject', and a few others
> >
> > However, when I try to create the fso object I keep receiving an
> > error.
> >
> > 'ActiveX component can't create object: 'Scripting.FileSystemObject'
> >
> > What am I missing?
> > All I am trying to do is delete a file on the onbeforeunload event.
> > I have spent the better part of two days on this.
> > All help greatly appreciated.
> >
> >
> >
>
>
>


Nov 19 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.