Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 19th, 2005, 07:27 AM
Mats
Guest
 
Posts: n/a
Default change a file name from asp (rather vbscript)

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
  #2  
Old July 19th, 2005, 07:27 AM
Ray at
Guest
 
Posts: n/a
Default Re: change a file name from asp (rather vbscript)

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" <webmaster@databyggarna.com> wrote in message
news:51955fa2.0308070321.2d4ca472@posting.google.c om...[color=blue]
> 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[/color]


  #3  
Old July 19th, 2005, 07:27 AM
Tom B
Guest
 
Posts: n/a
Default Re: change a file name from asp (rather vbscript)

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:eRO9GFOXDHA.2648@TK2MSFTNGP09.phx.gbl...[color=blue]
> 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" <webmaster@databyggarna.com> wrote in message
> news:51955fa2.0308070321.2d4ca472@posting.google.c om...[color=green]
> > 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[/color]
>
>[/color]


  #4  
Old July 19th, 2005, 07:27 AM
Ray at
Guest
 
Posts: n/a
Default Re: change a file name from asp (rather vbscript)

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

"Tom B" <shuckle@hotmail.com> wrote in message
news:OmdL5OOXDHA.1492@TK2MSFTNGP12.phx.gbl...[color=blue]
> 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:eRO9GFOXDHA.2648@TK2MSFTNGP09.phx.gbl...[color=green]
> > You're trying to name the FILE with a \ and : in it. The name of the[/color][/color]
file[color=blue][color=green]
> > would not be C:\boot.old; it would just be boot.old.
> >
> > Ray at work
> >
> > "Mats" <webmaster@databyggarna.com> wrote in message
> > news:51955fa2.0308070321.2d4ca472@posting.google.c om...[color=darkred]
> > > 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[/color][/color][/color]


  #5  
Old July 19th, 2005, 07:28 AM
Tom B
Guest
 
Posts: n/a
Default Re: change a file name from asp (rather vbscript)

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:%23vaMSUOXDHA.1004@TK2MSFTNGP12.phx.gbl...[color=blue]
> I'll bet you a dollar. :P
>
> Actually, I think that after he corrects the filename line, he will then[/color]
run[color=blue]
> into the permissions problem you suggest. For the love of God, I would[/color]
hope[color=blue]
> that IUSR doesn't have rights to boot.ini.
>
> Ray at work
>
> "Tom B" <shuckle@hotmail.com> wrote in message
> news:OmdL5OOXDHA.1492@TK2MSFTNGP12.phx.gbl...[color=green]
> > 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:eRO9GFOXDHA.2648@TK2MSFTNGP09.phx.gbl...[color=darkred]
> > > You're trying to name the FILE with a \ and : in it. The name of the[/color][/color]
> file[color=green][color=darkred]
> > > would not be C:\boot.old; it would just be boot.old.
> > >
> > > Ray at work
> > >
> > > "Mats" <webmaster@databyggarna.com> wrote in message
> > > news:51955fa2.0308070321.2d4ca472@posting.google.c om...
> > > > As there is no change filename command in vbscript you have to take[/color][/color][/color]
a[color=blue][color=green][color=darkred]
> > > > 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[/color][/color]
>
>[/color]


  #6  
Old July 19th, 2005, 07:29 AM
Ray at
Guest
 
Posts: n/a
Default Re: change a file name from asp (rather vbscript)

The fso is what has the deletefile method, not the file (fs).

Ray at home

--
Will trade ASP help for SQL Server help


"Mats" <webmaster@databyggarna.com> wrote in message
news:51955fa2.0308071417.1c175987@posting.google.c om...[color=blue]
> 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" <shuckle@hotmail.com> wrote in message[/color]
news:<es1aagOXDHA.2204@TK2MSFTNGP12.phx.gbl>...[color=blue][color=green]
> > 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[/color][/color]
second[color=blue][color=green]
> > code did.
> >
> > Perhaps Aaron should update
> > http://www.aspfaq.com/show.asp?id=2074
> > to reflect that
> >[/color][/color]


 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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 Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles