i'm creating a program using Code Blocks with GNU\GCC compiler.
i'm using Windows 10 with Windows Defender.
my program create a txt files(instead a text files, we can speak binary files too), but the Windows Defender can delete the file(and i have sure), for avoid these problem i must disable the Windows Defender.
my question is: can i compile my program(even using a compiler\linker flag) for avoid the Windows Defender problems?
ok.... i can disable the Windows Defender and make an exception.... but if i share my program, the new user will get the same problem :(
can anyone advice me more?

I'm going with "not enough detail about the problem." It's like I put a blindfold on you and asked you to describe the animal.

Remember the story of three blind men and an elephant?

Windows is heading towards app signing. This may be easier with Visual Studio and no, I will not enter into a dialog about FOSS or such.

i'm using Code Blocks with GNU compiler...
my program create a text file.. but the created file is deleted by Windows Defender...
i can create an exception on Windows Defender for my program... but when i use my program on another pc, the problem remains :(
on compilation, is the any flag that avoid that problem?
or i must use a win32 function for tell the Windows Defender that the text file is safe?

Still too little detail. Text files have not raised Windows Defender issues here. But if I were to write in system folders then I bet WD would complain.

As to use a win32 function I'm going with no because if it was that easy to disable WD, then WD and other antimalware apps would be defenseless against rogue apps and more.

Think about sharing details. What folder you are writing in and maybe some code that triggers the issue.

ok maybe you have right.. i'm using on my Documents folder... the text file is created close the exe file... and maybe you have right about it.
just for test: what folders i can use without WD don't complain?

Sorry but that's not clear enough for me. Here I have apps that write in their distribution folder and no issues. WD might ask for permission to connect to the web or such but nothing is wrong there.

The world has changed and the wide open old Windows system is changing to avoid catastrophes by blocking possible rogue actions by apps.

Why not start by sharing a minimum viable example that shows the problem? If you don't shared details, everyone is guessing.

seems that i get your point.. i'm trying search if GNU have that option... but i must search more(yes i don't use Visual Studio).
thank you so much for all

As to GNU signing options you can research that but here at the office where we craft and send out apps we would spending too much time finding out why the GCC or such is creating the problem. While we buy the Pro version of VS I have to wonder why this is an issue when folk want to make a Windows app when there are free versions of VS. Sometimes you run into someone that is campaigning for "only FOSS" which may conflict with the goal of app making that does this or that while avoiding other issues.

So here we are without details, no code, no minimal viable example so I'm left to chat about other areas. When you are ready, try sharing the deep dark (?) details.

thanks to you i have learned more... thank you so much for all

And now for something completely different.

To avoid all this, have you tried crafting what you want to do in Python?

PS. How's this for a triple dose of Python? Wink wink, nudge nudge.

commented: Say no more. +15

Why don't you rewrite your code so the settings are saved inside the software not on a text file on the hard drive which is a potential security threat? Your method is very messy of saving settings to a text file on the disk outside the software. That needs fixing. Many hackers drop files like this. Yours may be safe but many files randomy dropped by an application are a potential threat to security hence Windows Defender deletes them.

But if I were to write in system folders then I bet WD would complain.

That would result in a UAC popup rather than an alert/response from Windows Defender. I have written quite a few applications in c, vb.net c#, python, etc. I have never had to sign anything and I have never had a problem with Windows Defender.

commented: cambalinho needs to share how we can duplicate the issue. Without details, I would be guessing but you can get WD to pop up under many conditions. +15

after i disable the folder protection, on WD, the file isn't deleted.
is the only solution that i have now... but, like i said, isn't a solution on another computer.. unless we do the same

@cam, which is exactly what is needed to make progress. I didn't read that till now but was guessing it.

WD and most OSes are not going to allow an app to write files in system protected folders. For that sort of work you use an installer.

What is this you are writing? Let's hope it's no virus or such.

My guess is that WD wouldn't be flagging it unless it had a signature matching a known virus. As I said before, typically UAC intercepts any attempts to write to protected folders.

commented: Above there's a passage "close the exe" so we're left to guess it is some executable. But what is it? OP needs to spill the beans. +0
  • i run my compiled program;
  • the program is executed without a problem..
  • when i create(from my program) the text file, the WD delete my text file.
    the text file is only for get C++ code lines... nothing more.

Reverend Jim: "As I said before, typically UAC intercepts any attemots to write to protected folders."
if i use a resource file with name version and more(speaking about my compiled program), will resolve the problem?

commented: Please tell a lot more. It hampers getting to what's going on. And no. +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.