change a file name from asp (rather vbscript)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mats

    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.createob ject("scripting .filesystemobje ct")
    set fs = fso.GetFile("c: \boot.ini")
    fs.name = "c:\boot.ol d"
    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

    #2
    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@data byggarna.com> wrote in message
    news:51955fa2.0 308070321.2d4ca 472@posting.goo gle.com...[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.createob ject("scripting .filesystemobje ct")
    > set fs = fso.GetFile("c: \boot.ini")
    > fs.name = "c:\boot.ol d"
    > 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]


    Comment

    • Tom B

      #3
      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_machinenam e?

      "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
      news:eRO9GFOXDH A.2648@TK2MSFTN GP09.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@data byggarna.com> wrote in message
      > news:51955fa2.0 308070321.2d4ca 472@posting.goo gle.com...[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.createob ject("scripting .filesystemobje ct")
      > > set fs = fso.GetFile("c: \boot.ini")
      > > fs.name = "c:\boot.ol d"
      > > 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]


      Comment

      • Ray at

        #4
        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@hotmai l.com> wrote in message
        news:OmdL5OOXDH A.1492@TK2MSFTN GP12.phx.gbl...[color=blue]
        > I don't think that's a problem.
        >
        > Did you give permission for blabla.txt to be manipulated by
        > IUSR_machinenam e?
        >
        > "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
        > news:eRO9GFOXDH A.2648@TK2MSFTN GP09.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@data byggarna.com> wrote in message
        > > news:51955fa2.0 308070321.2d4ca 472@posting.goo gle.com...[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.createob ject("scripting .filesystemobje ct")
        > > > set fs = fso.GetFile("c: \boot.ini")
        > > > fs.name = "c:\boot.ol d"
        > > > set fs = nothing
        > > > set fso = nothing
        > > > %>
        > > > a) never[/color][/color][/color]


        Comment

        • Tom B

          #5
          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

          to reflect that

          <%@ Language = "VBScript" %>
          <html>
          <body>
          <%
          set fso = server.createob ject("scripting .filesystemobje ct")
          set fs = fso.GetFile("c: \blabla.txt")
          fs.name = "blabla.old "
          set fs = nothing
          set fso = nothing
          %>
          <%
          Set fso = Server.CreateOb ject("Scripting .FileSystemObje ct")
          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:%23vaMSUOX DHA.1004@TK2MSF TNGP12.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@hotmai l.com> wrote in message
          > news:OmdL5OOXDH A.1492@TK2MSFTN GP12.phx.gbl...[color=green]
          > > I don't think that's a problem.
          > >
          > > Did you give permission for blabla.txt to be manipulated by
          > > IUSR_machinenam e?
          > >
          > > "Ray at <%=sLocation% >" <myfirstname at lane34 dot com> wrote in message
          > > news:eRO9GFOXDH A.2648@TK2MSFTN GP09.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@data byggarna.com> wrote in message
          > > > news:51955fa2.0 308070321.2d4ca 472@posting.goo gle.com...
          > > > > 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.createob ject("scripting .filesystemobje ct")
          > > > > set fs = fso.GetFile("c: \boot.ini")
          > > > > fs.name = "c:\boot.ol d"
          > > > > set fs = nothing
          > > > > set fso = nothing
          > > > > %>
          > > > > a) never[/color][/color]
          >
          >[/color]


          Comment

          • Ray at

            #6
            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@data byggarna.com> wrote in message
            news:51955fa2.0 308071417.1c175 987@posting.goo gle.com...[color=blue]
            > Hi
            > You copy some code, and add some files, and then testing....
            > I've never tried this part of Scripting.FileS ystemObject 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_machinenam e anything what so ever in root....
            > After giving IUSR_machinenam e 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@hotmai l.com> wrote in message[/color]
            news:<es1aagOXD HA.2204@TK2MSFT NGP12.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]


            Comment

            Working...