change a file name from asp (rather vbscript)

Discussion in 'ASP General' started by Mats, Aug 7, 2003.

  1. Mats

    Mats Guest

    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
     
    Mats, Aug 7, 2003
    #1
    1. Advertising

  2. Mats

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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
     
    Ray at, Aug 7, 2003
    #2
    1. Advertising

  3. Mats

    Tom B Guest

    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:...
    > 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" <> wrote in message
    > news:...
    > > 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

    >
    >
     
    Tom B, Aug 7, 2003
    #3
  4. Mats

    Ray at Guest

    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" <> wrote in message
    news:...
    > 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:...
    > > 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" <> wrote in message
    > > news:...
    > > > 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
     
    Ray at, Aug 7, 2003
    #4
  5. Mats

    Tom B Guest

    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:%...
    > 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" <> wrote in message
    > news:...
    > > 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:...
    > > > 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" <> wrote in message
    > > > news:...
    > > > > 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

    >
    >
     
    Tom B, Aug 7, 2003
    #5
  6. Mats

    Ray at Guest

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

    Ray at home

    --
    Will trade ASP help for SQL Server help


    "Mats" <> wrote in message
    news:...
    > 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" <> wrote in message

    news:<>...
    > > 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
    > >
     
    Ray at, Aug 8, 2003
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sean
    Replies:
    5
    Views:
    897
  2. Austin
    Replies:
    8
    Views:
    926
    VisionSet
    Nov 18, 2003
  3. J
    Replies:
    6
    Views:
    475
    Jonathan Turkanis
    Feb 10, 2004
  4. David C. Holley

    Getting a ASP file name via VBScript

    David C. Holley, May 4, 2004, in forum: ASP General
    Replies:
    2
    Views:
    118
    David Holley
    May 4, 2004
  5. Greg Hauptmann
    Replies:
    5
    Views:
    180
    David A. Black
    Jan 20, 2009
Loading...

Share This Page