473,387 Members | 1,545 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 2545
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.