Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Aug 4th, 2005, 9:35 AM   #1
guzpapir
Newbie
 
Join Date: Aug 2005
Posts: 4
Rep Power: 0 guzpapir is on a distinguished road
Deleting files through vbs in html

I tried to use this code to delete files:

<HTML>
<HEAD><TITLE>No namer</TITLE>
<SCRIPT LANGUAGE="VBScript">
<!--
Path1 = "C:\Example"

Dim fso 
Dim oFolder
Dim oFile
Dim oSubFolder

  Set fso = createobject("Scripting.FileSystemObject")
  
   Set oFolder = fso.GetFolder(Path1)
  
  For Each oFile In oFolder.files
       If Right(lcase(oFile.Name,4)) = ".txt" Then
        oFile.Delete True
    End If
-->
</SCRIPT>
</HEAD>
<BODY>
....


but it doenst work,so if someone could show me the other way to do this I would really appriciate it.
guzpapir is offline   Reply With Quote
Old Aug 4th, 2005, 9:55 AM   #2
Berto
Programming Guru
 
Join Date: Aug 2004
Posts: 1,022
Rep Power: 6 Berto is on a distinguished road
Send a message via AIM to Berto Send a message via MSN to Berto
i dont think you can execute any commands using javascript otherwise it would make it insecure as buggery.
__________________
"Put your hand on a hot stove for a minute, and it seems like an hour. Sit with a pretty girl for an hour, and it seems like a minute. THAT'S relativity."

- Albert Einstein
Berto is offline   Reply With Quote
Old Aug 4th, 2005, 9:58 AM   #3
skuinders
Hobbyist Programmer
 
skuinders's Avatar
 
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4 skuinders is on a distinguished road
I am no Windows programmer... but isn't VBScript parsed on the server-side?
__________________
"A stupid man's report of what a clever man says can never be accurate, because he unconciously translates what he hears into something he can understand."
- B. Russell

http://web.bryant.edu/~srk2
skuinders is offline   Reply With Quote
Old Aug 4th, 2005, 9:59 AM   #4
big_k105
PFO Founder

 
big_k105's Avatar
 
Join Date: Mar 2004
Location: Fargo, ND
Posts: 1,630
Rep Power: 10 big_k105 is on a distinguished road
Send a message via AIM to big_k105 Send a message via MSN to big_k105 Send a message via Yahoo to big_k105
Im pretty sure VBScript is done on the Client-Side, but then again I'm not 100% on that tho.
__________________
BIG K aka Kyle
Programming Forums
Kyle K Online

Please do not PM or email me programming questions. Post them in the forums instead.
big_k105 is offline   Reply With Quote
Old Aug 4th, 2005, 10:05 AM   #5
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Both...

"VBScript was created by Microsoft to use either as a client-side scripting language for the Microsoft Internet Explorer (versions 3.0 and later) or as a server-side scripting language with the Microsoft Internet Information Server (versions 3.0 and later). A primary advantage for using the server-side approach is that the VBScript is processed by the server before it is transmitted to the client. Therefore, the client only receives an HTML page and we do not have to concern ourselves as to whether the browser can interpret the VBScript. In contrast, by using the client-side approach, you purposely transfer the work load to the browser in order to reduce the work load of the server. "

http://www.devguru.com/Technologies/...ipt_intro.html
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Aug 4th, 2005, 1:47 PM   #6
guzpapir
Newbie
 
Join Date: Aug 2005
Posts: 4
Rep Power: 0 guzpapir is on a distinguished road
OK,never mind,is there a way to do this using javascript???
guzpapir is offline   Reply With Quote
Old Aug 4th, 2005, 2:05 PM   #7
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
I'm assuming a VBScript is sandboxed if it's in a browser? Maybe you need to find a way to make your script have the required permissions to touch the local filesystem.
There is no way to do anything file i/o related on the client side with JavaScript.
Cerulean is offline   Reply With Quote
Old Aug 4th, 2005, 2:50 PM   #8
Dameon
Troll
 
Dameon's Avatar
 
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4 Dameon is on a distinguished road
Yes, VBS is sanboxed in the browser. Should run ok if you put the script in a .vbs file.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270
Dameon is offline   Reply With Quote
Old Aug 27th, 2005, 11:14 AM   #9
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
You can actually manipulate files with JavaScript on Windows machines, though strictly speaking Microsoft appropriate it and call it MS JScript under these circumstances:

var fs = new ActiveXObject("Scripting.FileSystemObject");
var sh = new ActiveXObject("WScript.Shell");

(The second one there is another interesting example; a shell object, with which you can run programs etc.) The objects are the same ones you'd use from VBScript, and have all the same contents - though obviously you use the slightly different JavaScript syntax in this context.

Either VBScript or 'JScript' will be, as Dameon said, sandboxed in the browser if the HTML file was loaded over the network. I don't recall whether this causes the scripts to actually fail, or just ask the user for confirmation, announcing that the scripts are trying to use potentially dangerous objects. If the file was loaded from the local file system, as far as I know, creating the filesystem, shell or other useful (and potentially extremely dangerous) objects should work just as it does in a VBScript or JScript run through WSH (i.e. stored in a file with a .vbs or .js extension).

Although come to think of it, there are infamous cases of ActiveX Objects mysteriously working when they shouldn't inside the sandbox; like Scriptlet.TypeLib. IE used to allow untrusted pages to create Scriptlet.TypeLibs silently; great, except Scriptlet.TypeLib has a write() method which can write an arbitrary file. Good old MS. This is how the KAK worm spread. I think it's safe to say this doesn't work any more
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

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

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
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:17 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC