change a file name from asp (rather vbscript)

M

Mats

As there is no change filename command in vbscript you have to take a
diversion.
According to aspfaq http://www.aspfaq.com/show.asp?id=2074
the following should work:
<%
set fso = server.createobject("scripting.filesystemobject")
set fs = fso.GetFile("c:\boot.ini")
fs.name = "c:\boot.old"
set fs = nothing
set fso = nothing
%>
a) never rename boot.ini b) in "real life" you have to get the
relative path to the file.
I do exactly the above swapping boot.ini for blabla.txt (and
blabla.old)
This returns a script error (0x800A0005) 'Invalid procedure call or
argument'
asfaq has in http://www.aspfaq.com/show.asp?id=2101 some suggestions
that I think does not apply to this situation
Win XP Pro and IIS 5 (not surprising) both patched as much as possible
At the moment it's not necessary to solve the problem but it will be
later on
Mats
 
R

Ray at

You're trying to name the FILE with a \ and : in it. The name of the file
would not be C:\boot.old; it would just be boot.old.

Ray at work
 
T

Tom B

I don't think that's a problem.

Did you give permission for blabla.txt to be manipulated by
IUSR_machinename?
 
R

Ray at

I'll bet you a dollar. :p

Actually, I think that after he corrects the filename line, he will then run
into the permissions problem you suggest. For the love of God, I would hope
that IUSR doesn't have rights to boot.ini.

Ray at work
 
T

Tom B

Do you take paypal?
I tried the following, I gave permission for the iusr_mymachine for full
control of my c: drive.
Obviously I commented out one section to test the other.
The first code wouldn't work with c:\blabla.old (as Ray said) but the second
code did.

Perhaps Aaron should update
http://www.aspfaq.com/show.asp?id=2074
to reflect that

<%@ Language = "VBScript" %>
<html>
<body>
<%
set fso = server.createobject("scripting.filesystemobject")
set fs = fso.GetFile("c:\blabla.txt")
fs.name = "blabla.old"
set fs = nothing
set fso = nothing
%>
<%
Set fso = Server.CreateObject("Scripting.FileSystemObject")
fso.moveFile "c:\blabla.txt", "c:\blabla.old"
Set fso = Nothing
%>

</body>
</html>
<%



%>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top