Changing the attributes for a hidden system file programmatically

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

    #1

    Changing the attributes for a hidden system file programmatically

    Hi,



    I have a hidden system file that I need to read.

    I am logged in as an administrator.

    I can not change the file attributes using the windows explorer.

    I can view the file's content.



    Opening the file programmaticall y fails with access is denied.

    (If I copy the file I can access it, although it is also hidden.)

    Therefore I am trying to change the attributes of that file,
    programmaticall y, to normal.

    Getting the attributes succeeds and shows that the file is hidden and
    system.

    However when I try to set the file attribute to normal it fails and get
    last error produces the following string :

    Error 183 : Cannot create file when that file already exists.



    The MSDN states that for WinXP it is possible to change the attributes
    for hidden and system files.

    Do I need some special permissions ? Which ones ?



    I have logged off and logged in again, the behavior did not change.



    Any leads, anyone ?



    Thank you!




  • Nishant Sivakumar

    #2
    Re: Changing the attributes for a hidden system file programmaticall y

    You may have to remove the system-file attribute before being able to remove
    the regular attributes like hidden and readonly.

    --
    Regards,
    Nish [VC++ MVP]


    "Alexandra" <alexandra.lev@ gmail.com> wrote in message
    news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[color=blue]
    > Hi,
    >
    >
    >
    > I have a hidden system file that I need to read.
    >
    > I am logged in as an administrator.
    >
    > I can not change the file attributes using the windows explorer.
    >
    > I can view the file's content.
    >
    >
    >
    > Opening the file programmaticall y fails with access is denied.
    >
    > (If I copy the file I can access it, although it is also hidden.)
    >
    > Therefore I am trying to change the attributes of that file,
    > programmaticall y, to normal.
    >
    > Getting the attributes succeeds and shows that the file is hidden and
    > system.
    >
    > However when I try to set the file attribute to normal it fails and get
    > last error produces the following string :
    >
    > Error 183 : Cannot create file when that file already exists.
    >
    >
    >
    > The MSDN states that for WinXP it is possible to change the attributes for
    > hidden and system files.
    >
    > Do I need some special permissions ? Which ones ?
    >
    >
    >
    > I have logged off and logged in again, the behavior did not change.
    >
    >
    >
    > Any leads, anyone ?
    >
    >
    >
    > Thank you!
    >
    >
    >
    >[/color]


    Comment

    • William DePalo [MVP VC++ ]

      #3
      Re: Changing the attributes for a hidden system file programmaticall y

      "Alexandra" <alexandra.lev@ gmail.com> wrote in message
      news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[color=blue]
      > I have a hidden system file that I need to read.
      >
      > I am logged in as an administrator.[/color]

      OK.
      [color=blue]
      > I can not change the file attributes using the windows explorer.
      >
      > I can view the file's content.[/color]

      OK.
      [color=blue]
      > Opening the file programmaticall y fails with access is denied.[/color]

      Important bits of information that you don't offer are the parameters to
      CreateFile(). Are you specifying an access mode of GENERIC_READ and a share
      mode of FILE_SHARE_READ ?
      [color=blue]
      > (If I copy the file I can access it, although it is also hidden.)
      >
      > Therefore I am trying to change the attributes of that file,
      > programmaticall y, to normal.
      >
      > Getting the attributes succeeds and shows that the file is hidden and
      > system.
      >
      > However when I try to set the file attribute to normal it fails and get
      > last error produces the following string :
      >
      > Error 183 : Cannot create file when that file already exists.[/color]

      Hmm. I think you'll need to post a _short_ snippet of code here that causes
      the error if the previous suggestion does not work for you.

      Regards,
      Will


      Comment

      • Nishant Sivakumar

        #4
        Re: Changing the attributes for a hidden system file programmaticall y

        BTW I am talking about doing it via Explorer (which only allows you to set
        readonly and hidden). You'll have to use attrib.exe to set the system
        attribute.

        --
        Regards,
        Nish [VC++ MVP]


        "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
        news:%23jCsLXu6 FHA.3880@TK2MSF TNGP12.phx.gbl. ..[color=blue]
        > You may have to remove the system-file attribute before being able to
        > remove the regular attributes like hidden and readonly.
        >
        > --
        > Regards,
        > Nish [VC++ MVP]
        >
        >
        > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
        > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[color=green]
        >> Hi,
        >>
        >>
        >>
        >> I have a hidden system file that I need to read.
        >>
        >> I am logged in as an administrator.
        >>
        >> I can not change the file attributes using the windows explorer.
        >>
        >> I can view the file's content.
        >>
        >>
        >>
        >> Opening the file programmaticall y fails with access is denied.
        >>
        >> (If I copy the file I can access it, although it is also hidden.)
        >>
        >> Therefore I am trying to change the attributes of that file,
        >> programmaticall y, to normal.
        >>
        >> Getting the attributes succeeds and shows that the file is hidden and
        >> system.
        >>
        >> However when I try to set the file attribute to normal it fails and get
        >> last error produces the following string :
        >>
        >> Error 183 : Cannot create file when that file already exists.
        >>
        >>
        >>
        >> The MSDN states that for WinXP it is possible to change the attributes
        >> for hidden and system files.
        >>
        >> Do I need some special permissions ? Which ones ?
        >>
        >>
        >>
        >> I have logged off and logged in again, the behavior did not change.
        >>
        >>
        >>
        >> Any leads, anyone ?
        >>
        >>
        >>
        >> Thank you!
        >>
        >>
        >>
        >>[/color]
        >
        >[/color]


        Comment

        • Gary Chanson

          #5
          Re: Changing the attributes for a hidden system file programmaticall y


          "Alexandra" <alexandra.lev@ gmail.com> wrote in message
          news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[color=blue]
          > Hi,
          >
          >
          >
          > I have a hidden system file that I need to read.
          >
          > I am logged in as an administrator.
          >
          > I can not change the file attributes using the windows explorer.
          >
          > I can view the file's content.
          >
          >
          >
          > Opening the file programmaticall y fails with access is denied.
          >
          > (If I copy the file I can access it, although it is also hidden.)
          >
          > Therefore I am trying to change the attributes of that file,
          > programmaticall y, to normal.
          >
          > Getting the attributes succeeds and shows that the file is hidden and
          > system.
          >
          > However when I try to set the file attribute to normal it fails and get
          > last error produces the following string :
          >
          > Error 183 : Cannot create file when that file already exists.
          >
          >
          >
          > The MSDN states that for WinXP it is possible to change the attributes
          > for hidden and system files.
          >
          > Do I need some special permissions ? Which ones ?
          >
          >
          >
          > I have logged off and logged in again, the behavior did not change.[/color]

          I think your real problem is that the file is in use by another program.

          --
          -GJC [MS Windows SDK MVP]
          -Software Consultant (Embedded systems and Real Time Controls)
          - http://www.mvps.org/ArcaneIncantations/consulting.htm
          -gchanson@mvps.o rg

          Comment

          • Alexandra

            #6
            Re: Changing the attributes for a hidden system file programmaticall y

            I am trying to open the file in write and read mode.
            This the code :

            DWORD attrs = GetFileAttribut es((LPCSTR)path );
            attrs = FILE_ATTRIBUTE_ NORMAL;
            if(SetFileAttri butes((LPCSTR)p ath,attrs))
            LogMessage("Set to FILE_ATTRIBUTE_ NORMAL");

            CFileException e;
            int res = file.Open(sPath + DBFileNewLocati on,CFile::modeR eadWrite,&e);

            "William DePalo [MVP VC++ ]" <willd.no.spam@ mvps.org> wrote in message
            news:OI1XQYu6FH A.3876@TK2MSFTN GP09.phx.gbl:
            [color=blue]
            > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
            > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...
            >[color=green]
            > > I have a hidden system file that I need to read.
            > >
            > > I am logged in as an administrator.[/color]
            >
            >
            > OK.
            >
            >[color=green]
            > > I can not change the file attributes using the windows explorer.
            > >
            > > I can view the file's content.[/color]
            >
            >
            > OK.
            >
            >[color=green]
            > > Opening the file programmaticall y fails with access is denied.[/color]
            >
            >
            > Important bits of information that you don't offer are the parameters to
            > CreateFile(). Are you specifying an access mode of GENERIC_READ and a share
            > mode of FILE_SHARE_READ ?
            >
            >[color=green]
            > > (If I copy the file I can access it, although it is also hidden.)
            > >
            > > Therefore I am trying to change the attributes of that file,
            > > programmaticall y, to normal.
            > >
            > > Getting the attributes succeeds and shows that the file is hidden and
            > > system.
            > >
            > > However when I try to set the file attribute to normal it fails and get
            > > last error produces the following string :
            > >
            > > Error 183 : Cannot create file when that file already exists.[/color]
            >
            >
            > Hmm. I think you'll need to post a _short_ snippet of code here that causes
            > the error if the previous suggestion does not work for you.
            >
            > Regards,
            > Will[/color]

            Comment

            • Alexandra

              #7
              Re: Changing the attributes for a hidden system file programmaticall y

              I have the same feeling.
              This file is used by a service which is logged in as a system account.
              However I have stopped the service, disabled it actually, logged out and
              logged in again.
              The service is disabled, stopped, I have checked.

              If I copy this file I can open the copy of that file...

              How can I find out if any other program is using that file ?
              Any suggestions you might have would be greatly appreciated...

              Thanks!!!

              "Gary Chanson" <gjchanson@_NO_ SPAM_comcast.ne t> wrote in message
              news:O057heu6FH A.1416@TK2MSFTN GP09.phx.gbl:
              [color=blue]
              > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
              > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...
              >[color=green]
              > > Hi,
              > >
              > >
              > >
              > > I have a hidden system file that I need to read.
              > >
              > > I am logged in as an administrator.
              > >
              > > I can not change the file attributes using the windows explorer.
              > >
              > > I can view the file's content.
              > >
              > >
              > >
              > > Opening the file programmaticall y fails with access is denied.
              > >
              > > (If I copy the file I can access it, although it is also hidden.)
              > >
              > > Therefore I am trying to change the attributes of that file,
              > > programmaticall y, to normal.
              > >
              > > Getting the attributes succeeds and shows that the file is hidden and
              > > system.
              > >
              > > However when I try to set the file attribute to normal it fails and get
              > > last error produces the following string :
              > >
              > > Error 183 : Cannot create file when that file already exists.
              > >
              > >
              > >
              > > The MSDN states that for WinXP it is possible to change the attributes
              > > for hidden and system files.
              > >
              > > Do I need some special permissions ? Which ones ?
              > >
              > >
              > >
              > > I have logged off and logged in again, the behavior did not change.[/color]
              >
              >
              > I think your real problem is that the file is in use by another program.
              >
              > --
              > -GJC [MS Windows SDK MVP]
              > -Software Consultant (Embedded systems and Real Time Controls)
              > - http://www.mvps.org/ArcaneIncantations/consulting.htm
              > -gchanson@mvps.o rg[/color]

              Comment

              • CheckAbdoul

                #8
                Re: Changing the attributes for a hidden system file programmaticall y

                Use the process explorer tool from www.sysinternals.com to find out the
                process that is using the file.

                --
                Cheers
                Check Abdoul
                -----------------

                "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                news:uzU4Fpu6FH A.808@TK2MSFTNG P09.phx.gbl...[color=blue]
                > I have the same feeling.
                > This file is used by a service which is logged in as a system account.
                > However I have stopped the service, disabled it actually, logged out and
                > logged in again.
                > The service is disabled, stopped, I have checked.
                >
                > If I copy this file I can open the copy of that file...
                >
                > How can I find out if any other program is using that file ?
                > Any suggestions you might have would be greatly appreciated...
                >
                > Thanks!!!
                >
                > "Gary Chanson" <gjchanson@_NO_ SPAM_comcast.ne t> wrote in message
                > news:O057heu6FH A.1416@TK2MSFTN GP09.phx.gbl:
                >[color=green]
                > > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                > > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...
                > >[color=darkred]
                > > > Hi,
                > > >
                > > >
                > > >
                > > > I have a hidden system file that I need to read.
                > > >
                > > > I am logged in as an administrator.
                > > >
                > > > I can not change the file attributes using the windows explorer.
                > > >
                > > > I can view the file's content.
                > > >
                > > >
                > > >
                > > > Opening the file programmaticall y fails with access is denied.
                > > >
                > > > (If I copy the file I can access it, although it is also hidden.)
                > > >
                > > > Therefore I am trying to change the attributes of that file,
                > > > programmaticall y, to normal.
                > > >
                > > > Getting the attributes succeeds and shows that the file is hidden and
                > > > system.
                > > >
                > > > However when I try to set the file attribute to normal it fails and[/color][/color][/color]
                get[color=blue][color=green][color=darkred]
                > > > last error produces the following string :
                > > >
                > > > Error 183 : Cannot create file when that file already exists.
                > > >
                > > >
                > > >
                > > > The MSDN states that for WinXP it is possible to change the attributes
                > > > for hidden and system files.
                > > >
                > > > Do I need some special permissions ? Which ones ?
                > > >
                > > >
                > > >
                > > > I have logged off and logged in again, the behavior did not change.[/color]
                > >
                > >
                > > I think your real problem is that the file is in use by another program.
                > >
                > > --
                > > -GJC [MS Windows SDK MVP]
                > > -Software Consultant (Embedded systems and Real Time Controls)
                > > - http://www.mvps.org/ArcaneIncantations/consulting.htm
                > > -gchanson@mvps.o rg[/color]
                >[/color]


                Comment

                • Alexandra

                  #9
                  Re: Changing the attributes for a hidden system file programmaticall y

                  Just tried the attrib.exe.
                  Same problem.
                  Access denied.

                  How can I find out what is preventing me from accessing that file ???

                  "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                  news:uuc#hau6FH A.3804@TK2MSFTN GP14.phx.gbl:
                  [color=blue]
                  > BTW I am talking about doing it via Explorer (which only allows you to set
                  > readonly and hidden). You'll have to use attrib.exe to set the system
                  > attribute.
                  >
                  > --
                  > Regards,
                  > Nish [VC++ MVP]
                  >
                  >
                  > "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                  > news:%23jCsLXu6 FHA.3880@TK2MSF TNGP12.phx.gbl. ..
                  >[color=green]
                  > > You may have to remove the system-file attribute before being able to
                  > > remove the regular attributes like hidden and readonly.
                  > >
                  > > --
                  > > Regards,
                  > > Nish [VC++ MVP]
                  > >
                  > >
                  > > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                  > > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[/color]
                  >[color=green][color=darkred]
                  > >> Hi,
                  > >>
                  > >>
                  > >>
                  > >> I have a hidden system file that I need to read.
                  > >>
                  > >> I am logged in as an administrator.
                  > >>
                  > >> I can not change the file attributes using the windows explorer.
                  > >>
                  > >> I can view the file's content.
                  > >>
                  > >>
                  > >>
                  > >> Opening the file programmaticall y fails with access is denied.
                  > >>
                  > >> (If I copy the file I can access it, although it is also hidden.)
                  > >>
                  > >> Therefore I am trying to change the attributes of that file,
                  > >> programmaticall y, to normal.
                  > >>
                  > >> Getting the attributes succeeds and shows that the file is hidden and
                  > >> system.
                  > >>
                  > >> However when I try to set the file attribute to normal it fails and get
                  > >> last error produces the following string :
                  > >>
                  > >> Error 183 : Cannot create file when that file already exists.
                  > >>
                  > >>
                  > >>
                  > >> The MSDN states that for WinXP it is possible to change the attributes
                  > >> for hidden and system files.
                  > >>
                  > >> Do I need some special permissions ? Which ones ?
                  > >>
                  > >>
                  > >>
                  > >> I have logged off and logged in again, the behavior did not change.
                  > >>
                  > >>
                  > >>
                  > >> Any leads, anyone ?
                  > >>
                  > >>
                  > >>
                  > >> Thank you!
                  > >>
                  > >>
                  > >>
                  > >>[/color]
                  > >[/color]
                  >[color=green]
                  > >[/color][/color]

                  Comment

                  • William DePalo [MVP VC++ ]

                    #10
                    Re: Changing the attributes for a hidden system file programmaticall y

                    "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                    news:uRz9mnu6FH A.3752@tk2msftn gp13.phx.gbl...[color=blue]
                    >I am trying to open the file in write and read mode.
                    > This the code :
                    >
                    > DWORD attrs = GetFileAttribut es((LPCSTR)path );
                    > attrs = FILE_ATTRIBUTE_ NORMAL;
                    > if(SetFileAttri butes((LPCSTR)p ath,attrs))
                    > LogMessage("Set to FILE_ATTRIBUTE_ NORMAL");
                    >
                    > CFileException e;
                    > int res = file.Open(sPath + DBFileNewLocati on,CFile::modeR eadWrite,&e);[/color]

                    Well, if understood your post correctly, you said that you were able to read
                    the file interactively. You never said that you were able to _write_
                    interactively but rather that you were copying the file data to a new
                    location.

                    If I have that right, I'd suggest that you change CFile::modeRead Write to
                    CFile::modeRead .

                    Regards,
                    Will


                    Comment

                    • Nishant Sivakumar

                      #11
                      Re: Changing the attributes for a hidden system file programmaticall y

                      Looks like that file is in use.

                      --
                      Regards,
                      Nish [VC++ MVP]


                      "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                      news:OgPxfuu6FH A.476@TK2MSFTNG P15.phx.gbl...[color=blue]
                      > Just tried the attrib.exe.
                      > Same problem.
                      > Access denied.
                      >
                      > How can I find out what is preventing me from accessing that file ???
                      >
                      > "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                      > news:uuc#hau6FH A.3804@TK2MSFTN GP14.phx.gbl:
                      >[color=green]
                      >> BTW I am talking about doing it via Explorer (which only allows you to
                      >> set
                      >> readonly and hidden). You'll have to use attrib.exe to set the system
                      >> attribute.
                      >>
                      >> --
                      >> Regards,
                      >> Nish [VC++ MVP]
                      >>
                      >>
                      >> "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                      >> news:%23jCsLXu6 FHA.3880@TK2MSF TNGP12.phx.gbl. ..
                      >>[color=darkred]
                      >> > You may have to remove the system-file attribute before being able to
                      >> > remove the regular attributes like hidden and readonly.
                      >> >
                      >> > --
                      >> > Regards,
                      >> > Nish [VC++ MVP]
                      >> >
                      >> >
                      >> > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                      >> > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[/color]
                      >>[color=darkred]
                      >> >> Hi,
                      >> >>
                      >> >>
                      >> >>
                      >> >> I have a hidden system file that I need to read.
                      >> >>
                      >> >> I am logged in as an administrator.
                      >> >>
                      >> >> I can not change the file attributes using the windows explorer.
                      >> >>
                      >> >> I can view the file's content.
                      >> >>
                      >> >>
                      >> >>
                      >> >> Opening the file programmaticall y fails with access is denied.
                      >> >>
                      >> >> (If I copy the file I can access it, although it is also hidden.)
                      >> >>
                      >> >> Therefore I am trying to change the attributes of that file,
                      >> >> programmaticall y, to normal.
                      >> >>
                      >> >> Getting the attributes succeeds and shows that the file is hidden and
                      >> >> system.
                      >> >>
                      >> >> However when I try to set the file attribute to normal it fails and
                      >> >> get
                      >> >> last error produces the following string :
                      >> >>
                      >> >> Error 183 : Cannot create file when that file already exists.
                      >> >>
                      >> >>
                      >> >>
                      >> >> The MSDN states that for WinXP it is possible to change the attributes
                      >> >> for hidden and system files.
                      >> >>
                      >> >> Do I need some special permissions ? Which ones ?
                      >> >>
                      >> >>
                      >> >>
                      >> >> I have logged off and logged in again, the behavior did not change.
                      >> >>
                      >> >>
                      >> >>
                      >> >> Any leads, anyone ?
                      >> >>
                      >> >>
                      >> >>
                      >> >> Thank you!
                      >> >>
                      >> >>
                      >> >>
                      >> >>
                      >> >[/color]
                      >>[color=darkred]
                      >> >[/color][/color]
                      >[/color]


                      Comment

                      • Alexandra

                        #12
                        Re: Changing the attributes for a hidden system file programmaticall y

                        According to this tool no process has the handle to my file...

                        What else can it be ?

                        "CheckAbdou l" <checkabdoul at mvps dot org> wrote in message
                        news:#91ogru6FH A.632@TK2MSFTNG P10.phx.gbl:
                        [color=blue]
                        > Use the process explorer tool from www.sysinternals.com to find out the
                        > process that is using the file.
                        >
                        > --
                        > Cheers
                        > Check Abdoul
                        > -----------------
                        >
                        > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                        > news:uzU4Fpu6FH A.808@TK2MSFTNG P09.phx.gbl...
                        >[color=green]
                        > > I have the same feeling.
                        > > This file is used by a service which is logged in as a system account.
                        > > However I have stopped the service, disabled it actually, logged out and
                        > > logged in again.
                        > > The service is disabled, stopped, I have checked.
                        > >
                        > > If I copy this file I can open the copy of that file...
                        > >
                        > > How can I find out if any other program is using that file ?
                        > > Any suggestions you might have would be greatly appreciated...
                        > >
                        > > Thanks!!!
                        > >
                        > > "Gary Chanson" <gjchanson@_NO_ SPAM_comcast.ne t> wrote in message
                        > > news:O057heu6FH A.1416@TK2MSFTN GP09.phx.gbl:
                        > >[/color]
                        >[color=green][color=darkred]
                        > > > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                        > > > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...
                        > > >[/color][/color]
                        >[color=green][color=darkred]
                        > > > > Hi,
                        > > > >
                        > > > >
                        > > > >
                        > > > > I have a hidden system file that I need to read.
                        > > > >
                        > > > > I am logged in as an administrator.
                        > > > >
                        > > > > I can not change the file attributes using the windows explorer.
                        > > > >
                        > > > > I can view the file's content.
                        > > > >
                        > > > >
                        > > > >
                        > > > > Opening the file programmaticall y fails with access is denied.
                        > > > >
                        > > > > (If I copy the file I can access it, although it is also hidden.)
                        > > > >
                        > > > > Therefore I am trying to change the attributes of that file,
                        > > > > programmaticall y, to normal.
                        > > > >
                        > > > > Getting the attributes succeeds and shows that the file is hidden and
                        > > > > system.
                        > > > >
                        > > > > However when I try to set the file attribute to normal it fails and[/color][/color]
                        >
                        > get
                        >[color=green][color=darkred]
                        > > > > last error produces the following string :
                        > > > >
                        > > > > Error 183 : Cannot create file when that file already exists.
                        > > > >
                        > > > >
                        > > > >
                        > > > > The MSDN states that for WinXP it is possible to change the attributes
                        > > > > for hidden and system files.
                        > > > >
                        > > > > Do I need some special permissions ? Which ones ?
                        > > > >
                        > > > >
                        > > > >
                        > > > > I have logged off and logged in again, the behavior did not change.
                        > > >
                        > > >[/color][/color]
                        >[color=green][color=darkred]
                        > > > I think your real problem is that the file is in use by another program.
                        > > >
                        > > > --
                        > > > -GJC [MS Windows SDK MVP]
                        > > > -Software Consultant (Embedded systems and Real Time Controls)
                        > > > - http://www.mvps.org/ArcaneIncantations/consulting.htm
                        > > > -gchanson@mvps.o rg[/color][/color]
                        >[color=green]
                        > >[/color][/color]

                        Comment

                        • Alexandra

                          #13
                          Re: Changing the attributes for a hidden system file programmaticall y

                          Just tried the process explorer tool from sysinternals and it does not
                          show that any process has a handle to my file...

                          "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                          news:#Q8o31u6FH A.3880@TK2MSFTN GP12.phx.gbl:
                          [color=blue]
                          > Looks like that file is in use.
                          >
                          > --
                          > Regards,
                          > Nish [VC++ MVP]
                          >
                          >
                          > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                          > news:OgPxfuu6FH A.476@TK2MSFTNG P15.phx.gbl...
                          >[color=green]
                          > > Just tried the attrib.exe.
                          > > Same problem.
                          > > Access denied.
                          > >
                          > > How can I find out what is preventing me from accessing that file ???
                          > >
                          > > "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                          > > news:uuc#hau6FH A.3804@TK2MSFTN GP14.phx.gbl:
                          > >[/color]
                          >[color=green][color=darkred]
                          > >> BTW I am talking about doing it via Explorer (which only allows you to
                          > >> set
                          > >> readonly and hidden). You'll have to use attrib.exe to set the system
                          > >> attribute.
                          > >>
                          > >> --
                          > >> Regards,
                          > >> Nish [VC++ MVP]
                          > >>
                          > >>
                          > >> "Nishant Sivakumar" <nish@nospam.as ianetindia.com> wrote in message
                          > >> news:%23jCsLXu6 FHA.3880@TK2MSF TNGP12.phx.gbl. ..
                          > >>[/color][/color]
                          >[color=green][color=darkred]
                          > >> > You may have to remove the system-file attribute before being able to
                          > >> > remove the regular attributes like hidden and readonly.
                          > >> >
                          > >> > --
                          > >> > Regards,
                          > >> > Nish [VC++ MVP]
                          > >> >
                          > >> >
                          > >> > "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                          > >> > news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...
                          > >>[/color][/color]
                          >[color=green][color=darkred]
                          > >> >> Hi,
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> I have a hidden system file that I need to read.
                          > >> >>
                          > >> >> I am logged in as an administrator.
                          > >> >>
                          > >> >> I can not change the file attributes using the windows explorer.
                          > >> >>
                          > >> >> I can view the file's content.
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> Opening the file programmaticall y fails with access is denied.
                          > >> >>
                          > >> >> (If I copy the file I can access it, although it is also hidden.)
                          > >> >>
                          > >> >> Therefore I am trying to change the attributes of that file,
                          > >> >> programmaticall y, to normal.
                          > >> >>
                          > >> >> Getting the attributes succeeds and shows that the file is hidden and
                          > >> >> system.
                          > >> >>
                          > >> >> However when I try to set the file attribute to normal it fails and
                          > >> >> get
                          > >> >> last error produces the following string :
                          > >> >>
                          > >> >> Error 183 : Cannot create file when that file already exists.
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> The MSDN states that for WinXP it is possible to change the attributes
                          > >> >> for hidden and system files.
                          > >> >>
                          > >> >> Do I need some special permissions ? Which ones ?
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> I have logged off and logged in again, the behavior did not change.
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> Any leads, anyone ?
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >> Thank you!
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >>
                          > >> >
                          > >>
                          > >> >[/color][/color]
                          >[color=green]
                          > >[/color][/color]

                          Comment

                          • Max

                            #14
                            Re: Changing the attributes for a hidden system file programmaticall y

                            Check what permissions do you have on this file and who is the owner of the
                            file.

                            Even if you are using an administrator account you might not have necessary
                            permissions on certain files.

                            Good Luck,
                            Max

                            "Alexandra" <alexandra.lev@ gmail.com> wrote in message
                            news:uwmBkDu6FH A.3232@TK2MSFTN GP15.phx.gbl...[color=blue]
                            > Hi,
                            >
                            >
                            >
                            > I have a hidden system file that I need to read.
                            >
                            > I am logged in as an administrator.
                            >
                            > I can not change the file attributes using the windows explorer.
                            >
                            > I can view the file's content.
                            >
                            >
                            >
                            > Opening the file programmaticall y fails with access is denied.
                            >
                            > (If I copy the file I can access it, although it is also hidden.)
                            >
                            > Therefore I am trying to change the attributes of that file,
                            > programmaticall y, to normal.
                            >
                            > Getting the attributes succeeds and shows that the file is hidden and
                            > system.
                            >
                            > However when I try to set the file attribute to normal it fails and get
                            > last error produces the following string :
                            >
                            > Error 183 : Cannot create file when that file already exists.
                            >
                            >
                            >
                            > The MSDN states that for WinXP it is possible to change the attributes for
                            > hidden and system files.
                            >
                            > Do I need some special permissions ? Which ones ?
                            >
                            >
                            >
                            > I have logged off and logged in again, the behavior did not change.
                            >
                            >
                            >
                            > Any leads, anyone ?
                            >
                            >
                            >
                            > Thank you!
                            >
                            >
                            >
                            >[/color]


                            Comment

                            Working...