473,574 Members | 2,574 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Changing the attributes for a hidden system file programmaticall y

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!


Nov 17 '05 #1
13 2559
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******** ******@TK2MSFTN GP15.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 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!

Nov 17 '05 #2
"Alexandra" <al***********@ gmail.com> wrote in message
news:uw******** ******@TK2MSFTN GP15.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 programmaticall y 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,
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.


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.as ianetindia.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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******** ******@TK2MSFTN GP15.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 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!


Nov 17 '05 #4

"Alexandra" <al***********@ gmail.com> wrote in message
news:uw******** ******@TK2MSFTN GP15.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 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.


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.o rg

Nov 17 '05 #5
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++ ]" <wi***********@ mvps.org> wrote in message
news:OI******** ******@TK2MSFTN GP09.phx.gbl:
"Alexandra" <al***********@ gmail.com> wrote in message
news:uw******** ******@TK2MSFTN GP15.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 programmaticall y 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,
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.

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.ne t> wrote in message
news:O0******** ******@TK2MSFTN GP09.phx.gbl:
"Alexandra" <al***********@ gmail.com> wrote in message
news:uw******** ******@TK2MSFTN GP15.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 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.

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.o rg


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******** *****@TK2MSFTNG P09.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.ne t> wrote in message
news:O0******** ******@TK2MSFTN GP09.phx.gbl:
"Alexandra" <al***********@ gmail.com> wrote in message
news:uw******** ******@TK2MSFTN GP15.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 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.

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.o rg

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.as ianetindia.com> wrote in message
news:uu******** ******@TK2MSFTN GP14.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.as ianetindia.com> wrote in message
news:%2******** ********@TK2MSF TNGP12.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******** ******@TK2MSFTN GP15.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 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!



Nov 17 '05 #9
"Alexandra" <al***********@ gmail.com> wrote in message
news:uR******** ******@tk2msftn gp13.phx.gbl...
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);


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
Nov 17 '05 #10

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

Similar topics

5
3845
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 attributes. For example, right now, I am looking for the rowsource property for a field in a table. How do I find that?
3
26251
by: StGo | last post by:
How can i read/write file's custom attributs(like subject,author...) in C#??? Thanks :))
7
12232
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 these file attributes.
1
1087
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
3469
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>..... I want to completely seperate the code from presentation. I would like to do the same thing for a value of a hidden form field but
2
12316
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 standard streamreader, textreader or file classes I get an access denied error message (which I expect). If I go Start | Run and type this in, I get...
1
1796
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: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wcedata5/html/wce50lrfsetfileattributes.asp can anyone direct me in the right direction?
12
4521
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 another forum from Peter Huang that said that an id="bg" as follows... <body MS_POSITIONING="GridLayout" runat="server" id="bg"> then we could do...
3
2768
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. Thanks for any hints. Urs.
0
7737
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8253
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7827
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8109
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5632
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3752
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2253
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1356
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.