![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Aug 2005
Posts: 4
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Programming Guru
![]() |
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 |
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: MA, US
Posts: 204
Rep Power: 4
![]() |
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 |
|
|
|
|
|
#4 |
|
PFO Founder
![]() ![]() |
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. |
|
|
|
|
|
#5 |
|
Programming Guru
![]() ![]() ![]() |
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." |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Aug 2005
Posts: 4
Rep Power: 0
![]() |
OK,never mind,is there a way to do this using javascript???
|
|
|
|
|
|
#7 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
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. |
|
|
|
|
|
#8 |
|
Troll
Join Date: Apr 2005
Location: Texas
Posts: 732
Rep Power: 4
![]() |
Yes, VBS is sanboxed in the browser. Should run ok if you put the script in a .vbs file.
__________________
MD5(sig) = bcef75433db02e9ad9bf81d6f7c5c270 |
|
|
|
|
|
#9 |
|
Professional Programmer
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4
![]() |
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 ![]() |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|