472,356 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,356 software developers and data experts.

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 programmatically 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,
programmatically, 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!


Nov 17 '05 #1
13 2459
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" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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!

Nov 17 '05 #2
"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
I have a hidden system file that I need to read.

I am logged in as an administrator.
OK.
I can not change the file attributes using the windows explorer.

I can view the file's content.
OK.
Opening the file programmatically fails with access is denied.
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?
(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,
programmatically, 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.


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
Nov 17 '05 #3
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" <ni**@nospam.asianetindia.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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!


Nov 17 '05 #4

"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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.


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
-g*******@mvps.org

Nov 17 '05 #5
I am trying to open the file in write and read mode.
This the code :

DWORD attrs = GetFileAttributes((LPCSTR)path);
attrs = FILE_ATTRIBUTE_NORMAL;
if(SetFileAttributes((LPCSTR)path,attrs))
LogMessage("Set to FILE_ATTRIBUTE_NORMAL");

CFileException e;
int res = file.Open(sPath + DBFileNewLocation,CFile::modeReadWrite,&e);

"William DePalo [MVP VC++ ]" <wi***********@mvps.org> wrote in message
news:OI**************@TK2MSFTNGP09.phx.gbl:
"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
I have a hidden system file that I need to read.

I am logged in as an administrator.

OK.

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

I can view the file's content.

OK.

Opening the file programmatically fails with access is denied.

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?

(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,
programmatically, 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.

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


Nov 17 '05 #6
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.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl:
"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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.

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
-g*******@mvps.org


Nov 17 '05 #7
Use the process explorer tool from www.sysinternals.com to find out the
process that is using the file.

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

"Alexandra" <al***********@gmail.com> wrote in message
news:uz*************@TK2MSFTNGP09.phx.gbl...
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.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl:
"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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.

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
-g*******@mvps.org

Nov 17 '05 #8
Just tried the attrib.exe.
Same problem.
Access denied.

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

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:uu**************@TK2MSFTNGP14.phx.gbl:
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" <ni**@nospam.asianetindia.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...

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 programmatically 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,
programmatically, 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!



Nov 17 '05 #9
"Alexandra" <al***********@gmail.com> wrote in message
news:uR**************@tk2msftngp13.phx.gbl...
I am trying to open the file in write and read mode.
This the code :

DWORD attrs = GetFileAttributes((LPCSTR)path);
attrs = FILE_ATTRIBUTE_NORMAL;
if(SetFileAttributes((LPCSTR)path,attrs))
LogMessage("Set to FILE_ATTRIBUTE_NORMAL");

CFileException e;
int res = file.Open(sPath + DBFileNewLocation,CFile::modeReadWrite,&e);


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::modeReadWrite to
CFile::modeRead.

Regards,
Will
Nov 17 '05 #10
Looks like that file is in use.

--
Regards,
Nish [VC++ MVP]
"Alexandra" <al***********@gmail.com> wrote in message
news:Og*************@TK2MSFTNGP15.phx.gbl...
Just tried the attrib.exe.
Same problem.
Access denied.

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

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:uu**************@TK2MSFTNGP14.phx.gbl:
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" <ni**@nospam.asianetindia.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
> 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" <al***********@gmail.com> wrote in message
> news:uw**************@TK2MSFTNGP15.phx.gbl...

>> 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 programmatically 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,
>> programmatically, 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!
>>
>>
>>
>>
>

>

Nov 17 '05 #11
According to this tool no process has the handle to my file...

What else can it be ?

"CheckAbdoul" <checkabdoul at mvps dot org> wrote in message
news:#9*************@TK2MSFTNGP10.phx.gbl:
Use the process explorer tool from www.sysinternals.com to find out the
process that is using the file.

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

"Alexandra" <al***********@gmail.com> wrote in message
news:uz*************@TK2MSFTNGP09.phx.gbl...
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.net> wrote in message
news:O0**************@TK2MSFTNGP09.phx.gbl:

"Alexandra" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
> programmatically, 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.

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
-g*******@mvps.org



Nov 17 '05 #12
Just tried the process explorer tool from sysinternals and it does not
show that any process has a handle to my file...

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:#Q**************@TK2MSFTNGP12.phx.gbl:
Looks like that file is in use.

--
Regards,
Nish [VC++ MVP]
"Alexandra" <al***********@gmail.com> wrote in message
news:Og*************@TK2MSFTNGP15.phx.gbl...
Just tried the attrib.exe.
Same problem.
Access denied.

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

"Nishant Sivakumar" <ni**@nospam.asianetindia.com> wrote in message
news:uu**************@TK2MSFTNGP14.phx.gbl:

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" <ni**@nospam.asianetindia.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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" <al***********@gmail.com> wrote in message
> news:uw**************@TK2MSFTNGP15.phx.gbl...
> 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 programmatically 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,
>> programmatically, 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!
>>
>>
>>
>>
>

>



Nov 17 '05 #13
Max
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" <al***********@gmail.com> wrote in message
news:uw**************@TK2MSFTNGP15.phx.gbl...
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 programmatically 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,
programmatically, 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!

Nov 17 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: WindAndWaves | last post by:
Greetings once more, I was wondering if someone figured out the difference between attributes and properties. I noticed that things like fields have a number of properties, but also...
3
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
7
by: John R. | last post by:
How do you set the following file attributes: Compressed Encrypted Normal ReparsePoint SparsePoint You CAN'T set these using FileInfo.Attributes or File.SetAttributes. It doesn't work for...
1
by: Mike | last post by:
Hi, I have a peculiar problem with trying to assess FileInfo Attributes. I am trying to do something like this FileInfo* fi = new FileInfo(fileName); if (fi->Attributes & Hidden) { // ...
14
by: Paul | last post by:
I want to set the page title and/or a form hidden field programatically through ASP.Net. I do not want to use something like... <% sTitle ="My Title" %> <html><title><%=sTitle%></title>..... ...
2
by: Glen Conway | last post by:
Hi, I am trying to get the contents of a file in a hidden share on a remote server, something like '\\server.domain.com\c$\program files\application\document.xml'. When I try any of the...
1
by: Benjamin | last post by:
I am trying to make a file I created a hidden file. I think I need to use the setfileattribute() but I cannot find it anywhere. I found this on msdn:...
12
by: GaryDean | last post by:
In the original post I failed so indicate that I am using framework 1.1....... I need to be able to change the background color of a page from code. I found an answer to this question in...
3
by: Urs | last post by:
Hi How do I change the value of an HTML HIDDEN INPUT field from code behind (VB or C#)? I need this (invisible) field for some javascript to gather information once the page has been loaded....
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.