Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > change a file name from asp (rather vbscript)

Reply
Thread Tools

change a file name from asp (rather vbscript)

 
 
Mats
Guest
Posts: n/a
 
      08-07-2003
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
 
Reply With Quote
 
 
 
 
Ray at
Guest
Posts: n/a
 
      08-07-2003
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

"Mats" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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



 
Reply With Quote
 
 
 
 
Tom B
Guest
Posts: n/a
 
      08-07-2003
I don't think that's a problem.

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

"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:(E-Mail Removed)...
> 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
>
> "Mats" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > 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

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      08-07-2003
I'll bet you a dollar.

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

"Tom B" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I don't think that's a problem.
>
> Did you give permission for blabla.txt to be manipulated by
> IUSR_machinename?
>
> "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> > "Mats" <(E-Mail Removed)> wrote in message
> > news:(E-Mail Removed) om...
> > > 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



 
Reply With Quote
 
Tom B
Guest
Posts: n/a
 
      08-07-2003
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>
<%



%>
"Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
news:%(E-Mail Removed)...
> I'll bet you a dollar.
>
> 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
>
> "Tom B" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > I don't think that's a problem.
> >
> > Did you give permission for blabla.txt to be manipulated by
> > IUSR_machinename?
> >
> > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
> > news:(E-Mail Removed)...
> > > 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
> > >
> > > "Mats" <(E-Mail Removed)> wrote in message
> > > news:(E-Mail Removed) om...
> > > > 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

>
>



 
Reply With Quote
 
Ray at
Guest
Posts: n/a
 
      08-08-2003
The fso is what has the deletefile method, not the file (fs).

Ray at home

--
Will trade ASP help for SQL Server help


"Mats" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> Hi
> You copy some code, and add some files, and then testing....
> I've never tried this part of Scripting.FileSystemObject before.
> You think a page like aspfaq would know, but even the sun has spots
> they say
> I might not be fully aware of all aspects of vbscript, but so stupid
> that I allow IUSR_machinename anything what so ever in root....
> After giving IUSR_machinename permissions in the appropriate folder it
> worked just fine using only the filename in the "naming part".
> However fs.DeleteFile creates an error (0x800A01B6)
> Object doesn't support this property or method.
> It really doesn't matter, but out of curiosity I'd like to know why.
> Mats
> "Tom B" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > 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
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
A Paradise DNS address change? What change? There was no change. Tony Neville NZ Computing 7 09-22-2006 01:02 PM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
name = name.substring(0, name.lastIndexOf('.')); Help please Jack-2 Javascript 3 12-24-2003 04:39 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM



Advertisments